Question: public class Nth { public static void main(String[] args){ int[][] arr = { {1,0,1,0}, {1,1,0,1}, {1,0,0,1} }; int n = Integer.parseInt(args[0]); int[] col = new

public class Nth {

public static void main(String[] args){

int[][] arr = { {1,0,1,0},

{1,1,0,1},

{1,0,0,1} };

int n = Integer.parseInt(args[0]);

int[] col = new int[arr.length]; //[0,0,0,0]

for(int i = 0; i < arr.length; i ++){

col[i] = arr[i][n];

}

for(int i = 0; i < col.length; i++){

System.out.println(col[i]);

}

}

}

please explain, i dont get the part int[] col = new int[arr.length]; and col[i] = arr[i][n]; and why do we use for loop in this code

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!