java4all@1986 java. Powered by Blogger.

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.












0 comments:

Post a Comment

FaceBook Login

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

HTML/JAVASCRIPT

Total Pageviews

STATCOUNTER

  © Blogger template Simple n' Sweet by Ourblogtemplates.com 2009

Back to TOP