7 Replies Latest reply on May 31, 2011 9:52 AM by darrylburke

    map.get returns unexpected null

      I had written 2 classes and there output is also given. i would like to know the reason for null and any modification which i can do to get the value from map.
      public class TestBean {
           String str=null;
           TestBean(String str)
      public class Test {
           public static void main(String[] args) {
                Map map = new HashMap();
                TestBean t = new TestBean("junk");
                map.put(t, "buster");
                map.put(new TestBean("junk"), "buster");
                System.out.println(map.get(new TestBean("Harsh")));

      Edited by: EJP on 31/05/2011 17:31: corrected your title and added {noformat}
      {noformat} tags