title: How to store bytearrays in hashmap or hashtable in java
body: <p>Hi i have bytearrays of size 8 bytes each and i need to store them in a hashmap or hashtable. For example say i have 1000 blocks... then it will store 1st key and value(bytearray) and then when block2 is passed it should check if it is already present in hahtable and if not there it should increment and count should be incremented. I have written code to store but the problem is that it is not able to search, may be bacuse of the way i'm storing in byte array.</p>
  
  <p>Code:</p>
  
  <pre><code>int collisions = 0;
  Hashtable&lt;Integer, Long&gt; ht = new Hashtable&lt;Integer, Long&gt;();
  // Given bloc1 value here
  if(ht.contains(bloc1)) {
    collisions++;
  }
  else {
    ht.put(i,ByteBuffer.wrap(bloc1).getLong());
  }  
  </code></pre>
  
  <p>Problem is: ht.contains is not giving the desired o/p</p>