In HashSet duplicates are allowed while adding to the HashSet,
but while retreiving the object from HashSet is not shown the
duplicate values, WHY ?

Answer Posted / brijendra kumar (xavient)

Actually in HashSet we are able to add the duplicate value,
but at the execution time JVM ignore the duplicate value.
HashSet<String> T= new HashSet<String>();
T.add("k");
T.add("k");
System.out.println("size" +T.size());
when we execute these line of code then we got the size of
HashSet is 1.
Due to this reason we are unable to iterate the duplicate
value from HashSet.

Is This Answer Correct ?    7 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What are the different types of features of the java collections framework? : java collections

576


HOW MUCH PERCENTAGE WE DEDUCT FOR OUR SUPPLIERS OR OTHER PROFESSIONALS

1582


Which server-side script takes the input from JavaScript, can access the database if it needs to, and processes the data.

1602


please mail me the interview question based on java/j2ee

1537


In hyderabad, which s/w training center is best for java, other than corejava what r the new tools to learn in java,which tool is best & have current requirement,pls give me information about java to learn ?

1681






What are the considerations to be made in case of loops in java ?

571


What is the enumerator of the java collection framework? : java collections

567


Hi frnds how to lock an user when he enter wrong credentials more than 3 time using java or j2ee tech take username and password in a bean no need to connect DB and validate give me some sample application code or links its urgent for me thanks in advance

1880


What is the difference between comparable and comparator in java.util pkg?

594


What are the interfaces in java collections? : java collections

618


What are the classes in the java collection framework? : java collections

596


What is iterator in the java collections framework? : java collections

539


Which java collection class can be used to maintain the entries in the order in which they were last accessed?

562


Explain the OOPS concept in Realtime Scenarion ? Take example as CAR. Please explain indetail ?

2565


How do I find jre path in windows?

531