I get a print out where the rows and columns are not


JAVA

What would be the best way to print out a 2D array, and have the rows/columns line up, even if some of the elements are null(not initialized) and others are not? For example if I use a nested for loop to print out a 7x7 array...

for(int I = 0; I <7; i++){

for(int2 = 0; I<7; i2++){

System.out.println(array[i][i2])+" ");

}

System.out.println("");

}

I get a print out where the rows and columns are not aligned, when some of the elements are initialized and others are not. Hope that makes sense.

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: I get a print out where the rows and columns are not
Reference No:- TGS02905821

Now Priced at $10 (50% Discount)

Recommended (99%)

Rated (4.3/5)