Collator GetInstance() Example
Gets the Collator for the current default locale.
Collatorclass GetInstance() method example. This example shows you how to use GetInstance() method.This method Gets the Collator for the current default locale.
Here is the code:-
/*
* @Program that Gets the Collator for the current default locale.
* GetInstance.java
* Author:-RoseIndia Team
* Date:-16-Jun-2008
*/
import java.util.*;
import java.text.*;
public class GetInstance {
public static void main(String[] args) {
// Build a vector of words to be sorted
ArrayList list = new ArrayList();
list.add("R");
list.add("O");
list.add("S");
list.add("E");
Collator collate = Collator.getInstance();
CollationKey[] keys = new CollationKey[list.size()];
for (int k = 0; k < list.size(); k ++)
keys[k] = collate.getCollationKey((String)list.get(k));
for (int l= 0;l < keys.length; l++) {
System.out.println(keys[l].getSourceString());
}
}
}
|
|