- Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTreeSetExample.java
More file actions
Latest commit
29 lines (23 loc) · 511 Bytes
/
Copy pathTreeSetExample.java
File metadata and controls
29 lines (23 loc) · 511 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
packagecollection.Set;
importjava.util.Iterator;
importjava.util.Set;
importjava.util.TreeSet;
/* Output-
C
Java
JavaScript
Python
*/
publicclassTreeSetExample {
publicstaticvoidmain(String[] args) {
Set<String> list= newTreeSet<>();
list.add("Java");
list.add("Python");
list.add("C");
list.add("JavaScript");
Iterator<String> itr=list.iterator();
while(itr.hasNext())
System.out.println(itr.next());
System.out.println("Removed Element: "+list.remove("C"));
}
}