In HashSet duplicates are allowed while adding to the HashSet,
but while retreiving the object from HashSet is not shown the
duplicate values, WHY ?
Answers were Sorted based on User's Feedback
Answer / 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 |
Answer / shashi
Because HashSet class will override equals and hashcode method internally.
| Is This Answer Correct ? | 0 Yes | 0 No |
What is Visual Source Safe(source control Tool)?
Which java collection class can be used to maintain the entries in the order in which they were last accessed?
What are the different types of features of the java collections framework? : java collections
VSS Objectives
Which interface does java.util.hashtable implement?
What are the interfaces in java collections? : java collections
Should we create system software ( e.g operating system ) in java ?
Which of the following declaration is wrong? int i=45; float j = 45.0; double k=45.0;
What is the difference between Eclipse and MyEclipse?
Write a postfix expression to (a*(b+c/d)*d-e)
Which sorting algorithm is used by collections.sort() in java ?
what is diff string and stringbuffer