About 362,000 results
Open links in new tab
  1. How to Get Subarray in Java? - GeeksforGeeks

    Dec 9, 2024 · In Java, subarrays are the contiguous portion of an array. Extracting subarrays in Java is common when working with data that needs slicing or partitioning. Java does not have a direct method to create subarrays, we can extract subarrays using simple techniques like built-in methods or manual loops.

  2. Generating All Subarrays - GeeksforGeeks

    Feb 7, 2025 · Given an array arr [], the task is to generate all the possible subarrays of the given array. Examples: To generate a subarray, we need a starting index from the original array. For choosing the starting index, we can run a loop from [0 to n-1] and consider each i …

  3. How to create a sub array from another array in Java?

    There is also a nice way with Java 8 Streams: int[] subArr = IntStream.range(startInclusive, endExclusive) .map(i -> src[i]) .toArray(); The benefit about this is, it can be useful for many different types of "src" array and helps to improve writing pipeline operations on the stream.

  4. How to Create a Subarray in Java - Delft Stack

    Mar 4, 2025 · This tutorial will demonstrate how to create a subarray from another array in Java. Learn various methods including Arrays.copyOfRange, using loops, and the Stream API. Gain practical insights and code examples to enhance your programming skills.

  5. Subarrays, Subsequences, and Subsets in Array - GeeksforGeeks

    Jan 15, 2024 · A subarray is a contiguous part of array, i.e., Subarray is an array that is inside another array. In general, for an array of size n, there are n*(n+1)/2 non-empty subarrays. For example, Consider the array [1, 2, 3, 4], There are 10 non-empty sub-arrays.

  6. Find All Subarrays of a Given Array in Java - Online Tutorials Library

    Discover how to find all subarrays of a given array in Java with practical examples and clear explanations.

  7. Get a subarray of an array between specific index in Java

    Dec 8, 2021 · We can use the Java Stream, introduced in Java SE 8, to get a subarray from an array. The idea is to get a stream of elements between the specified range and then call the toArray() method to accumulate the stream elements into a new array.

  8. Slicing Arrays in Java - Baeldung

    Jan 8, 2024 · The ArrayUtils class has the subarray() method, which allows us to get a subarray quickly: String[] result = ArrayUtils.subarray(LANGUAGES, 1, 4); assertArrayEquals(JVM_LANGUAGES, result); As we can see, it’s pretty straightforward to solve the problem using the subarray() method.

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

    Aug 3, 2010 · There is no real way to wrap any data without copying and receive real array in Java. You just cannot create new array over existing memory. You have basically 2 options: Use methods that can accept range of array. This was already recommended.

  10. Create Subarray from Another Array in Java - Online Tutorials …

    Learn how to create a subarray from another array in Java with this easy-to-follow guide.

  11. Some results have been removed
Refresh