-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathSetList.java
More file actions
50 lines (38 loc) · 1005 Bytes
/
SetList.java
File metadata and controls
50 lines (38 loc) · 1005 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
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
package abc;
import java.util.*;
public class SetList {
public static void main(String[] Args)
{
//does not allow duplicate values in sets
//the methods used earlier will be used in all
/*
* three classes in Set Interfacei.e these three implement Set interface
* ------HashSet
* will not maintain the insertion order of the object
*
* ------LinkedHashSet
*
* ------TreeSet
*/
HashSet list=new HashSet();
list.add("Test");
list.add(123);
list.add(23124.2);
list.add(false);
list.add(false);
System.out.println(list);
//LINKED HASH SET
/*
* --------It is a subclass of HashSet Class
* -------- maintains the insertion order of the object
* --------no duplicacy allowed too
*/
LinkedHashSet list1= new LinkedHashSet();
list1.add("Test");
list1.add(123);
list1.add(23124.2);
list1.add(false);
list1.add(false);
System.out.println(list1);
}
}