[Code]
public static void main(String[] args) {
// TODO automatisch generierter Methodenstub
String [] array = {"y","x","x","y","z","y","x","y","z","z"};
List<String> list = new ArrayList<>(Arrays.asList(array));
TreeSet<String> ts = new TreeSet<>(list);
for(String s : ts) {
int count = 0;
for(String ss : list) {
if(s.equals(ss)) {
count++;
}
}
System.out.println(s + " " + count);
}
}
[Ausgabeergebnis] x 3 y 4 z 3
[Punkt]
Recommended Posts