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
Hi Friends, i have searched in google but not clear. can you give bank example with synchronized keyword
What are the interfaces in java collections? : java collections
can u draw class/object diagram for ATM
What is iterator in the java collections framework? : java collections
What are the different types of classes implemented in the set interfaces? : java collections
What are the differences between the java collection and the java list? : java collections
What are the classes in the java collection framework? : java collections
What are maps interfaces in the java collections? : java collections
What are the types of java collections? : java collections
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 ?
What is the enumerator of the java collection framework? : java collections
How do I find jre path in windows?
What is an algorithm in java collection framework? : java collections
What is the use of hashcode in java ?
Which interface does java.util.hashtable implement?