-
Notifications
You must be signed in to change notification settings - Fork 0
/
Set_.java
35 lines (32 loc) · 904 Bytes
/
Set_.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
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
/**
*
* @author 500062053
*/
import java.util.*;
public class Set_
{
public static void main(String[] args)
{
ArrayList a=new ArrayList();
Random r=new Random();
HashSet s=new HashSet();
for(int i=1;i<=12;i++)
{
int ob=r.nextInt(200);
a.add(ob);
}
System.out.println("List:"+a);
HashSet obj=new HashSet(a);
TreeSet obj1=new TreeSet(obj);
// HashSet obj=new HashSet(a);
//HashSet removes the duplicates and give output
//TreeSet makes them in Sorted order
System.out.println("Set:"+obj);
System.out.println("Set:"+obj1);
}
}