
please explain me d flow of this prog in detail
import java.util.*;
public class HashTreeLinkedhashset {
public static void main(String args[])
{
HashSet hs=new HashSet();
hs.add(new Integer(99));
System.out.println("sri");
hs.add("sri@jlc");
System.out.println("sri");
System.out.println(hs);
TreeSet ts= new TreeSet();
System.out.println(ts.add("sri"));
ts.add("sri@jlc");
System.out.println(ts.add("sri"));
ts.add("aaaa");
ts.add("cccc");
ts.add("bbbb");
System.out.println(ts);
}
}
Thanks

In the give code, an object of HashSet class is created.The add() method of this class then add an integer and a string value to it. The System.out.println(hs) then prints the values of HashSet.As HashSet is not ordered so it will display the hashset values in random order.
Then an object of TreeSet class is created. As add() method of TreeSet class is of boolean type so using System.out.println(ts.add("sri")), the value "sri" will get added to the TreeSet and display the true value on the console. The Set does not allow duplicate values so the value "sri" will not be added to the treeset again and when you add sri@jlc, it will display false value. The values "aaaa","cccc" and "bbbb" will directly added to the TreeSet and System.out.println(ts) display the Treeset values in random order as they are not ordered.
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.