可能重复:
排序的 ArrayList 不显示?
代码:
String title1 = "Original Order\n\n";
String title2 = "Sorted Order\n\n";
String collection = "";
for (int i = 0; i < cdcollection.size(); i++) {
collection = collection + cdcollection.get(i);
}
mainTextArea.setText(title1 + collection);
Collections.sort(cdcollection);
String temp = "";
for (int j = 0; j < cdcollection.size(); j++) {
temp += cdcollection.get(j);
}
mainTextArea.setText(title2 + temp);