java - how to return one row of an [n][3] array? -
i want return one,two or more rows of [n][3] array. example, array
{ {1,11,5}, {2,6,7}, {3,13,9}, {12,7,16}, {14,3,25}, {19,18,22}, {23,13,29}, {24,4,28} }
i want return {1,11,5}
or {2,6,7},{19,18,22},{24,4,28}
.how can this?
public static int[][] horizontal_view(int first, int end) { if (first == end) return * ; //i want return here 2 or more row of [8][3] array int mid = (first + end) / 2; int[][] x = horizontal_view(first, mid); int[][] y = horizontal_view(mid + 1, end); return merge(x, y); }
if won't modify array, can state:
int[] row = array[1];
in case modify row, , don't want modifications visible in array
, can clone array:
int[] rowclone = (int[]) array[1].clone();
Comments
Post a Comment