I was wondering how I could access the first and last row of this 2d arraylist.
public static ArrayList<Integer> list(ArrayList<ArrayList<Integer>> grid){
ArrayList<Integer> num = new ArrayList<>();
for(int i = 0; i < grid.size(); i++){
for( int j = 0; j <grid.get(i).size(); j++){
System.out.print(grid.get(i).get(j) + " ");
}
System.out.println();
}
this code will print out the entire arraylist. Is there a way to get the first row and last row only
3 4 1 2 8 6
6 1 8 2 7 4
5 4 3 9 9 5
5 9 8 3 2 6
8 7 2 9 6 4
iandjhave while the first row is being printed? What values do they have while the last row is being printed? You can either add moreprintcalls, or use the debugger to answer that question.