5. ข้อความ

The Camtasia Studio video content presented here requires JavaScript to be enabled and the latest version of the Macromedia Flash Player. If you are you using a browser with JavaScript disabled please enable it now. Otherwise, please update your version of the free Flash Player by downloading here.

 
รหัสที่ 5-21  โปรแกรมแสดงตัวอย่างการเปรียบเทียบสตริงไทย
import java.text.Collator;
import java.util.Locale;
// โปรแกรมแสดงตัวอย่างการเปรียบเทียบสตริงไทย 
public class ThaiString {
  public static void main(String[] args) {
    Collator thai = Collator.getInstance(new Locale("th"));
    System.out.println( thai.compare("เขย", "สะใภ้") );
    System.out.println( "เขย".compareTo("สะใภ้") );
  }
}
©2009 S.Prasitjutrakul