import java.io.PrintStream;
public class JavaApplication16 {
public static void main(String[] args) {
// Create 2-dimensional array.
String[][] values = new String[12][4];
String format;
format = "|%1$-30s|%2$-10s|%3$-20s|\n";
// Assign three elements in it.
values[0][0] = "Mnd";
values[0][1] = "Stroom";
values[0][2] = "Water";
values[0][3] = "Telefoon";
values[1][0] = "Jan";
values[1][1] = "1000";
values[1][2] = "1500";
values[2][0] = "Feb";
values[3][0] = "Mrt";
values[3][2] = "3";
// Loop over top-level arrays.
for (String[] sub : values) {
// Loop and display sub-arrays.
for (String sub1 : sub) {
PrintStream printf;
printf = System.out.printf(sub1 + " ");
}
System.out.println();
}
}
}
Output is:
Mnd Stroom Water Telefoon
Jan 1000 1500 null
Feb null null null
Mrt null 3 null
null null null null
null null null null
null null null null
null null null null
null null null null
null null null null
null null null null
null null null null
Aucun commentaire:
Enregistrer un commentaire