If I'm not mistaken, slicing in Python corresponds to extracting a subarray from the given array, so if you have an array like below:
int[][] vet = new int[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
Performing the following slicing vet[0:3][1] corresponds to retrieve an array with the elements 2, 5, 8 (second column from row 0 included to row 3 excluded).
Unfortunately, in Java this is not possible, at least not "vertically" since a 2D array is basically an array of arrays. Each "row" index identifies a sub-array but in reality there are now actual rows or columns, just arrays within another array.
What you could do is to use the Arrays.copyOfRange() method to slice an array "horizontally".
Integer[][] vet = new Integer[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
Integer[] subArray = new Integer[3];
subArray = Arrays.copyOfRange(vet[1], 0, 3); //Retrieves the elements [4, 5, 6]
Instead, for slicing "vertically" you need to write a utility method:
public static void main(String[] args) {
Integer[][] vet = new Integer[][]{{1, 2, 3}, {4, 5, 6}, {7, 8, 9}};
Integer[] subArray = new Integer[3];
verticalSlicing(vet, subArray, 1, 0, 3);
System.out.println(Arrays.toString(subArrayVert)); //Prints [2, 5, 8]
}
public static <T> void verticalSlicing(T[][] vet, T[] subArray, int col, int rowStart, int rowEnd) {
if (col < 0 || col > subArray.length || (rowEnd - rowStart) > subArray.length) {
return;
}
IntStream.range(rowStart, rowEnd).forEach(i -> subArray[i] = vet[i][col]);
}