Collator: getInstance(Locale desiredLocale) : Collator « java.text « Java by API






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

1.Collator.IDENTICAL
2.Collator.NO_DECOMPOSITION
3.Collator.CANONICAL_DECOMPOSITION
4.Collator.FULL_DECOMPOSITION
5.Collator.SECONDARY
6.Collator: getCollationKey(String source)
7.Collator.getInstance()
8.Collator: setDecomposition(int decompositionMode)
9.Collator: setStrength(int newStrength)