To identify duplicate keys in HasMap?Example
>> Tuesday, May 24, 2011
1.To identify duplicate keys in HasMap JVM internally uses equals() Method.
PROGRAM:
class DuplicateKey
{
HashMap hm=new HashMap();
hm.put("10","Bhaskar");
hm.put("10","Ajantha");
System.out.println(hm);
}
OUTPUT :
{10 , Ajantha}
In HashMap it overrides the duplicate key of it's values.
PROGRAM:
class DuplicateKey
{
HashMap hm=new HashMap();
hm.put("10","Bhaskar");
hm.put("10","Ajantha");
System.out.println(hm);
}
OUTPUT :
{10 , Ajantha}
In HashMap it overrides the duplicate key of it's values.
0 comments:
Post a Comment