title: Why does my HashMap.get returns null value even after putting proper key,value?
body: <p>I am trying to retrieve some values from a Hash Map, before returning the value I am checking if the key is present in the map or not, and this check always fails which results in null value. I have overridden hash Code and equals method as well. Could someone tell me what I am doing wrong here?</p>
  
  <p>class fields:</p>
  
  <pre><code> private static final List&lt;String&gt; DZ=new ArrayList&lt;String&gt;();
   private static final Map&lt;Participant,List&lt;String&gt;&gt; subDz=new HashMap&lt;Participant,List&lt;String&gt;&gt;();
  </code></pre>
  
  <p>Method where I am putting into the map:</p>
  
  <pre><code>    public static synchronized void handleSubs(String[] subData,String    dz){
      int[] lowdims=new int[subData.length];
      int[] highdims=new int[subData.length];
      try {
          for (int i=1;i&lt;subData.length;i++){
              if (!subData[i].equals("") &amp;&amp; !subData[i].equals("\n")){
                  if (i%2==0){
                      highdims[i]=Integer.parseInt(subData[i].trim());
                  }
                  else {
                      lowdims[i]=Integer.parseInt(subData[i].trim());
                  }
              }
          }
          if (!DZ.isEmpty()){
              DZ.clear();
          }
          DZ.add(dz);
          allSubDZs.add(dz);
          int[] newlow=removeZeroes(lowdims);
          int[] newhigh=removeZeroes(highdims);
          allSubs.add(new Participant(newlow,newhigh));
          subDz.put(new Participant(newlow,newhigh),DZ );
      }
  </code></pre>
  
  <p>Method where I am retrieving the values:</p>
  
  <pre><code>   public static List&lt;String&gt; getSubDz(Participant sub){
      if (subDz.containsKey(sub)){
          return subDz.get(sub);
      }
      else{
          logger.info("Subscription DZ not available");
          return null;
      }
  }
  </code></pre>
  
  <p>The if check in the getSubDz always fails, even though I put the key in it. </p>
  
  <p>hashCode and equals methods:</p>
  
  <pre><code>   @Override
     public int hashCode() {
      final int prime = 31;
      int result = 1;
      result = prime * result + ((DZ == null) ? 0 : DZ.hashCode());
      return result;
  }
     @Override
     public boolean equals(final Object obj) {
      if (this == obj) {
          return true;
      }
      if (obj == null) {
          return false;
      }
      if (this.getClass() != obj.getClass()) {
          return false;
      }
      final SubscriptionHandler other=(SubscriptionHandler)obj;
      if (DZ == null) {
          if (other.DZ != null) {
              return false;
          }
      } else if (!DZ.equals(other.DZ)) {
          return false;
      }
      return true;
  </code></pre>