-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHashSetDemo.java
More file actions
29 lines (21 loc) · 807 Bytes
/
Copy pathHashSetDemo.java
File metadata and controls
29 lines (21 loc) · 807 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
package oops;
import java.util.HashSet;
import java.util.TreeSet;
public class HashSetDemo {
public static void main(String[] args) {
HashSet<Bike> h=new HashSet<Bike>();
h.add(new Bike("bullet 350", "bs6", "royal enfield",125,345000));
h.add(new Bike("shine", "bs6", "honda",125,95000));
h.add(new Bike("hfdelux", "bs4", "hero",125,98000));
h.add(new Bike("rx100", "bs6", "bajaj",125,91000));
h.add(new Bike("unicorn", "bs6", "honda",125,145000));
h.add(new Bike("bullet 350", "bs6", "royal enfield",125,345000));
h.add(new Bike("rx100", "bs4", "bajaj",125,90000));
h.add(new Bike("rx100", "bs6", "bajaj",125,90000));
TreeSet<Bike> tr=new TreeSet<Bike>(h);
//System.out.println("tr");
for(Bike b:tr) {
System.out.println(b);
}
}
}