-
Notifications
You must be signed in to change notification settings - Fork 0
/
AldhiyaSet.java
65 lines (58 loc) · 1.16 KB
/
AldhiyaSet.java
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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
import java.util.ArrayList;
import java.util.HashSet;
import java.util.HashMap;
import java.util.Hashtable;
class aldi
{
public String name;
public aldi (String name)
{
this.name = name;
}
public boolean equals(Object obj)
{
if(!(obj instanceof aldi))
{
return super.equals(obj);
}
else
{
aldi comp = (aldi)obj;
return comp.hashCode() == obj.hashCode();
}
}
}
public class AldhiyaSet
{
public static void main (String[] args)
{
HashSet<aldi> set = new HashSet<aldi>();
ArrayList<aldi> list = new ArrayList<aldi>();
aldi a = new aldi("A");
aldi b = new aldi("B");
aldi c = new aldi("C");
set.add(a);
set.add(b);
set.add(c);
list.add(a);
list.add(b);
list.add(c);
System.out.println("Print List");
for(aldi h : list)
{
System.out.println(h.name);
}
System.out.println("");
System.out.println("Print Set");
for(aldi h : set)
{
System.out.println(h.name);
}
System.out.println("");
System.out.println("Print Map");
for(aldi h : set)
{
System.out.println(h.name);
}
}
}