import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.TreeSet;
public class LinkedHashSetTreeDemo {
public void operationHashSet()
{
HashSet
// add elements to the hash set
hs.add("B");
hs.add("B");
hs.add("A");
hs.add("D");
hs.add("E");
hs.add("C");
hs.add("F");
System.out.println("HASHSET ANY RANDOM OREDER"+hs);
}
public void operationLinkedHashSet()
{
LinkedHashSet
// add elements to the hash set
hs.add("B");
hs.add("B");
hs.add("A");
hs.add("D");
hs.add("E");
hs.add("C");
hs.add("F");
System.out.println("LINKED HASH SET SAME ORDER"+hs);
}
public void operationTreeSet()
{
TreeSet
// add elements to the hash set
hs.add("B");
hs.add("B");
hs.add("A");
hs.add("D");
hs.add("E");
hs.add("C");
hs.add("F");
System.out.println("TREE SET"+hs);
}
public static void main(String args[]) {
// create a hash set
LinkedHashSetTreeDemo lhs= new LinkedHashSetTreeDemo();
lhs.operationLinkedHashSet();
lhs.operationHashSet();
lhs.operationTreeSet();
}
}
1 comment:
I am very amazed by the information of this blog and i am glad that i had a look over the blog.
cdn stands for
Post a Comment