Javatpoint Logo

How to Add duplicate value in Set Interface?

By: vasant*** On: Mon Aug 12 11:01:28 EDT 2013     Question Reputation4 Answer Reputation3 Quiz Belt Series Points0  7Blank User
If it is possible mean , please give me one sample example code and explain the program.Up0Down

 
The definition of equality depends on the container. Usually it's the .equals()/.hashCode() relationship, but there are some containers that use identity for equality.Image Created0Down

By: [email protected] On: Mon Aug 12 11:06:25 EDT 2013 Question Reputation0 Answer Reputation153 Belt Series Points0 153User Image
Are You Satisfied :1Yes1No
 
Hi Umesh,
Thanks for your information, plz give me one sample example code.I am really confused on this topic.
Image Created0Down

By: [email protected] On: Mon Aug 12 11:33:05 EDT 2013 Question Reputation4 Answer Reputation3 Belt Series Points0 7User Image
Are You Satisfied :0Yes0No
 
HashMap does not permit duplicate keys. If you have two values with the same associated key, it retains which ever was "put" more recently, and loses the older value.


and
You cannot have a HashMap<Integer>; it needs two types. It has no add() method.
Image Created-2Down

By: [email protected] On: Tue Aug 13 02:18:50 EDT 2013 Question Reputation0 Answer Reputation392 Belt Series Points0 392User Image
Are You Satisfied :0Yes1No
 
Hi Ravimalik,
I am not asking Map interface(HashMap) , My question is how to add duplicate values in Set interface , for example (TreeSet)...
+Regards,
Vasanth
Image Created0Down

By: [email protected] On: Tue Aug 13 07:51:51 EDT 2013 Question Reputation4 Answer Reputation3 Belt Series Points0 7User Image
Are You Satisfied :0Yes0No