Java Data Type Tutorial - Java String CASE_INSENSITIVE_ORDER








Syntax

String.CASE_INSENSITIVE_ORDER has the following syntax.

public static final Comparator <String> CASE_INSENSITIVE_ORDER

Example

In the following code shows how to use String.CASE_INSENSITIVE_ORDER field.

/*w  ww . jav  a  2  s.  c  o  m*/

import java.util.Arrays;

public class Main {
  public static void main(String[] argv) {
    String[] rawStrings = {  "B", "java2s.com", "b","A", "a","c", "C" };
    System.out.println(Arrays.toString(rawStrings));
    Arrays.sort(rawStrings,String.CASE_INSENSITIVE_ORDER);
    System.out.println(Arrays.toString(rawStrings));

  }
}

The code above generates the following result.