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 are the types of interface used in the java collections? : java collections
What is IOC in spring?
please mail me the interview question based on java/j2ee
What are the main classes of the list interfaces? : java collections
How do you create UserTransaction Object? How do you rollback a transaction in a method?
Hi we have an urgent requirement for Java/J2ee technical lead position & also looking for "Java Guidewire claimcentre" experienced professional for Bangalore location if interested can reach srisanh@gmail.com
what debugging tool that can be used to debug the java programs?
wnet use DAO design in u r project?
What are the uses of the set interfaces in the java collections? : java collections
Write a postfix expression to (a*(b+c/d)*d-e)
What is need of DAO? Write one simple DAO example?
What is the enumerator of the java collection framework? : java collections