Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-4103436

Collator.compare not working properly

XMLWordPrintable

    • x86
    • windows_nt



      Name: joT67522 Date: 01/12/98


      Please save the following code into a file named
      a.java, compile and run it. You will be getting
      the following output:

      result1=0;
      result2=1

      The output should have been both 1 s since both
      "file access" and "fileaccess" are bigger than
      "file" . Thanks.

      -----------a.java------------------------------
      import java.text.Collator;
      import java.util.Locale;

      public class a
      {
      public static void main(String[] args)
      {
      Collator collator = Collator.getInstance(Locale.US);

      String reference = "file";
      String compare1 = "file access";
      String compare2 = "fileaccess";

      int result1 = collator.compare(compare1, reference);
      int result2 = collator.compare(compare2, reference);

      System.out.println("result1=" + result1);
      System.out.println("result2=" + result2);
      }
      }
      (Review ID: 22801)
      ======================================================================

            lwernersunw Laura Werner (Inactive)
            johsunw Joon Oh (Inactive)
            Votes:
            0 Vote for this issue
            Watchers:
            0 Start watching this issue

              Created:
              Updated:
              Resolved:
              Imported:
              Indexed: