title: Grab a segment of an array in Java without creating a new array on heap
body: <p>I'm looking for a method in Java that will return a segment of an array. An example would be to get the byte array containing the 4th and 5th bytes of a byte array. I don't want to have to create a new byte array in the heap memory just to do that.  Right now I have the following code:</p>
  
  <pre><code>doSomethingWithTwoBytes(byte[] twoByteArray);
  
  void someMethod(byte[] bigArray)
  {
        byte[] x = {bigArray[4], bigArray[5]};
        doSomethingWithTwoBytes(x);
  }
  </code></pre>
  
  <p>I'd like to know if there was a way to just do <code>doSomething(bigArray.getSubArray(4, 2))</code> where 4 is the offset and 2 is the length, for example.</p>