About 263,000 results
Open links in new tab
  1. How to create a sub array from another array in Java?

    A sub-array would be pointing to the original array like a sub-list. Changing an array element will not affect the original array whereas in a sub-array it would.

  2. How to get a sub array of array in Java, without copying data?

    Aug 3, 2010 · There is no way to declare a subarray in Java if you use built in arrays like byte []. The reason is: The length of the array is stored with the data, not with the declaration of the reference to it.

  3. Get only part of an Array in Java? - Stack Overflow

    The length of an array in Java is immutable. So, you need to copy the desired part into a new array. Use copyOfRange method from java.util.Arrays class:

  4. java - Algorithm to generate all Subarrays from initial Array - Stack ...

    Oct 17, 2022 · Here's the algorithm for generating all non-empty subarrays of the given array iteratively: Maintain two nested lists: one for subarrays that are in progress and the resulting list for subarrays …

  5. javascript - How to get subarray from array? - Stack Overflow

    Sep 24, 2011 · The slice () method returns a shallow copy of a portion of an array into a new array object selected from start to end (end not included) where start and end represent the index of items …

  6. Grab a segment of an array in Java without creating a new array on heap

    Jul 9, 2009 · 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 …

  7. How to get 2D subarray from 2D array in JAVA? - Stack Overflow

    May 3, 2013 · You could instantiate a new array and loop through the appropriate indices of the original array to initialize the subarray.

  8. java - Find an array inside another larger array - Stack Overflow

    Implement a function that finds an array in another larger array. It should accept two arrays as parameters and it will return the index of the first array where the second array first occurs in full. Eg, …

  9. Finding a sub array in an array in Java - Stack Overflow

    Nov 2, 2014 · I am trying to write a program using two methods that determines if a sub array is located within an array. subArray() is supposed to receive two arrays and return the index of the start of the …

  10. Slicing byte arrays in Java - Stack Overflow

    Aug 21, 2013 · I'm trying to slice a byte array to prune the first part of the array. I'm using ByteBuffer but it does not behave like I would expect. byte[] myArray = new byte[10]; ByteBuffer buf = ByteBuffer.w...