Is it possible to change the type of an array in Java?
<blockquote>
  <p><strong>Possible Duplicate:</strong><br>
  <a href="http://stackoverflow.com/questions/11437203/byte-array-to-int-array">byte array to Int Array</a>  </p>
</blockquote>



<p>I have a large array of bytes, can I somehow interpret it as an array of ints, such that each entry is just four of the original bytes?</p>

<p>I mean something like this:</p>

<pre><code>for (int i = 0; i &lt; byteArray.length; i += 4) {
    intArray[i / 4] = byteArray[i] &lt;&lt; 24 + byteArray[i+1] &lt;&lt; 16 + byteArray[i+2] &lt;&lt; 8 + byteArray[i+3];
}
</code></pre>

<p>but rather than copying the whole array byte by byte which takes forever because the array is huge, just read ints off the array that already exists.</p>
