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
What are the different types of ways where you can iterate over a list? : java collections
What are the considerations to be made in case of loops in java ?
What is java collection? : java collections
can u draw class/object diagram for ATM
What are the different types of classes implemented in the set interfaces? : java collections
Which sorting algorithm is used by collections.sort() in java ?
What are the different types of features of the java collections framework? : java collections
What do you understand by synchronization? Why is it important?
What are the queues in the java collection framework? : java collections
Should we create system software ( e.g operating system ) in java ?
my interviewer asked me what technical specification you used how to answer that question
What are the types of interface used in the java collections? : java collections
What are the uses of the set interfaces in the java collections? : java collections
Which server-side script takes the input from JavaScript, can access the database if it needs to, and processes the data.
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.?.