I am looking for some advice on how I can create a method that generates a 2D array based two parameters, an integer s that will dictate the number of rows of the 2D array and int x[] would be where different 1D arrays of length 20 will fill each row of the 2D array. So far this the the method that I came up with but it only fills each row with 0s only one row is filled with the input array. I basically need a to fill each row of a autogenerated 2D array with a bunch of same sized 1D arrays. please help. thx !
public class c {
public int [][] f;
public int [][] a(int x[], int s){
f = new int [s][20];
for(int j = 0; j < x.length; j++) {
f[s-1][j] = x[j];
}
return f;
}
public void d(){
for (int i =0; i < f.length; i++) {
for(int j = 0; j < f[i].length; j++) {
System.out.print(f[i][j] + " ");
}
System.out.println(" ");
}
}
}