Collator: getInstance(Locale desiredLocale)
import java.text.Collator;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Locale;
import javax.swing.JLabel;
public class MainClass {
public static void main(String[] args) {
ArrayList list = new ArrayList();
list.add("\u00e4pple");
list.add("banan");
list.add("p\u00e4ron");
list.add("orange");
// Obtain a Swedish collator
Collator collate = Collator.getInstance(new Locale("sv", ""));
Collections.sort(list, collate);
for (int i= 0;i < list.size(); i++) {
System.out.println(list.get(i));
}
}
}
Related examples in the same category