Skip to content

Instantly share code, notes, and snippets.

@gabhi
Created April 4, 2014 00:48
Show Gist options
  • Save gabhi/9965888 to your computer and use it in GitHub Desktop.
Save gabhi/9965888 to your computer and use it in GitHub Desktop.
slice array elements in forward direction
public static void arraySlicing(int[] inputArr) {
List<ArrayList<Integer>> result = new ArrayList<ArrayList<Integer>>();
for (int i = 0; i <= inputArr.length; i++) {
for (int j = i + 1; j <= inputArr.length; j++) {
System.out.println(Arrays.toString(Arrays.copyOfRange(inputArr, i, j)));
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment