Java Arrays sort String array in case insensitive order

Description

Java Arrays sort String array in case insensitive order

import java.util.Arrays;

public class Main {

  public static void main(String[] args) {

    String[] stringArray = { "java", "CSS", "html", "Javascript", "SQL" };

    System.out.println(Arrays.toString(stringArray));

    Arrays.sort(stringArray);//from   w ww .  j  a  v  a2 s .co m
    System.out.println(Arrays.toString(stringArray));

    
    Arrays.sort(stringArray, String.CASE_INSENSITIVE_ORDER);
    System.out.println(Arrays.toString(stringArray));


  }
}



PreviousNext

Related