char[][] isbns = {
{'9', '6', '0', '-', '4', '2', '5', '-', '0', '5', '9', '-', '0'},
{'8', '0', '-', '9', '0', '2', '7', '4', '4', '-', '1', '-', '6'},
{'0', '-', '8', '0', '4', '4', '-', '2', '9', '5', '8', '-', 'X'},
{'0', '-', '9', '4', '3', '3', '9', '6', '-', '0', '4', '-', '2'},
{'0', '-', '9', '7', '5', '2', '2', '9', '8', '-', '0', '-', '5'},
{'9', '9', '7', '1', '-', '5', '-', '0', '2', 'l', '0', '-', '0'},
{'9', '3', '-', '8', '6', '5', '4', '-', '-', '2', '1', '-', '4'},
{'9', '9', '9', '2', '1', '-', '5', '8', '8', '-', '1', '0', '7'}
};
array is as like this on top and my method is as follows
public static Object[] getColumn(char[][] arr, int index){
Object[] column = new Object[arr[0].length];
for(int i = 0; i < column.length; i++){
column[i] = arr[i][index];
}
return column;
}
However as rows are 8 and columns are 13 characters, i get array index out of bounds exception error.
How can i solve this issue ? thanks.
![How can i get a column from 2d array in java [duplicate]](https://file.115kc.com/storage/eg/image377.jpg)