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 |
VSS Objectives
Difference b/w >> and >>> ?
waht are architecture of web application?
what is the difference between checked and unchecked Exceptions?
Difference between Spring framework and Struts framework?
12 Answers IBM, L&T, VAM,
What are the differences between the java collection and the java list? : java collections
what is difference between web server and application server?
what is mean by hasing and maping in java platform and advantage?
who will give req's to u?. how they send req's to u? . what design documents contains?. when bugs raised on other developer code how to report to them?.(throgh mail or ........). how to retrive 100 recods from dao layer to presentation layer.using which collection?. what is sequence diagram.?.
What are the different types of features of the java collections framework? : java collections
How do I find jre path in windows?
What is the use of hashcode in java ?