package arrays;
import java.util.Iterator;
public class StringArray2D {
public static void main(String[] args) {
// TODO Auto-generated method stub
String row1[][]={{"Robert","Albert","Gilbert"},{"Fobert","Sobert","Nareg","Nari"},{"Marie","Sarie","Kharie","Aarie","Akiahsbdfuiah"}};
display2(row1);
}
public static void display2(String x[][]){
for (int row = 0; row < x.length; row++) {
for (int column = 0; column < x[row].length; column++) {
System.out.print(x[row][column] +"\t");
}
System.out.println();
}
}
public static void display(String x[][]){
for (int row = 0; row < x.length; row++) {
for (int column = 0; column < x[row].length; column++) {
System.out.println(x[row][column] + "\t");
}
System.out.println();
}
}
}
hello guys ... im trying to display this 2D array properly Proper Display
but instead i get the display like this Improper Display
the method "display2" works properly , the method "display" doesnt work properly what am i missing ?
lninSystem.out.printlnmeans? and how is it different fromSystem.out.print?display()is usingSystem.out.printlnwhich prints to a newline each time. Your code is fine.