Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


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



In HashSet duplicates are allowed while adding to the HashSet, but while retreiving the object fro..

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

In HashSet duplicates are allowed while adding to the HashSet, but while retreiving the object fro..

Answer / shashi

Because HashSet class will override equals and hashcode method internally.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Java J2EE AllOther Interview Questions

how to delete cookie information?and when it will delete?

3 Answers   SolutionNET,


What are the differences between the java collection and the java list? : java collections

0 Answers  


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.?.

0 Answers   iGate,


what debugging tool that can be used to debug the java programs?

1 Answers   Inforica,


where is JNDI being used in java platform?

2 Answers  


What are the considerations to be made in case of loops in java ?

0 Answers  


Is it possible to create Userdefined Unchecked Exception also?If Yes, give an example?

1 Answers   HCL,


which book is the best for preparing for SCWCD 1.5

4 Answers   Google,


2. Write a interface "Car" with the following methods void setName(String) String getName() void setColor(String) String getColor() void setModel(long) long getModel()

1 Answers  


when exactly should we use throws ,and wen exactly should we use the try and catch for exceptional handling

0 Answers  


Explain JSP life cycle?

2 Answers   Accenture,


Is it Mandatory to map each pojo class variable with table column in Hibernate? Is there any alternative to skip some of those? Thanks in advance...

2 Answers   Span Systems,


Categories