So richten Sie den String an der Konsolenausgabe aus
Ich muss Code schreiben für:
Ich habe den Code geschrieben:
public class tables {
public static void main(String[] args) {
//int[][] table = new int[12][12];
String table="";
for(int i=1; i<13; i++){
for(int j=1; j<13; j++){
//table[i-1][j-1] = i*j;
table+=(i*j)+" ";
}
System.out.println(table.trim());
table="";
}
}
}
Das Problem ist jedoch das Ausgabeformat. Ich brauche die Ausgabe in einer matrixartigen Art und Weise, wobei jede Zahl auf eine Breite von 4 formatiert ist (die Zahlen sind rechtsbündig und entfernen führende / nachfolgende Leerzeichen in jeder Zeile). Ich hatte es versuchtGoogle finde aber keine gute lösung für mein problem. Kann mir jemand helfen?