In diesem Teil des Codes:Anzeige jedes Listenelement in einer separaten Zeile (Konsole)
System.out.println("Alunos aprovados:");
String[] aprovados = {"d", "a", "c", "b"};
List<String> list = new ArrayList();
for (int i = 0; i < aprovados.length; i++) {
if (aprovados[i] != null) {
list.add(aprovados[i]);
}
}
aprovados = list.toArray(new String[list.size()]);
Arrays.sort(aprovados);
System.out.println(Arrays.asList(aprovados));
Ein Beispiel Ergebnis System.out.printin ist:
[a, b, c, d ]
Wie kann ich den obigen Code ändern, wenn ich ein Ergebnis wie unten möchte?
a
b
c
d
Oder zumindest:
a,
b,
c,
d
Danke! Das hat funktioniert :) – rsb2097
Eigentlich musste ich aprovados statt Liste eingeben, also: für (String-Element: [HAUPTNAME HIER]) { System.out.println (Element); } – rsb2097