Sort string array in case sensitive order and case insensitive order java

Here’s the java program on sort string array in case sensitive order and case insensitive order java,

Also read – sort string array in java

Sort string array in case sensitive order and case insensitive order java

Let’s see java program to sort string array in case-insensitive order and sensitive order,

import java.util.Arrays;
public class SortStringArrayDemo 
{
   public static void main(String[] args) 
   {
      String strPlaces[] = new String[]{"Great Barrier Reef", "denmark", "bora bora", 
"Florence","Tokyo", "cusco"};
      Arrays.sort(strPlaces);
      System.out.println("CASE SENSITIVE ORDER : ");
      System.out.println(Arrays.toString(strPlaces));
      Arrays.sort(strPlaces, String.CASE_INSENSITIVE_ORDER);
System.out.println("CASE INSENSITIVE ORDER : ");
System.out.println(Arrays.toString(strPlaces));
}
}

Output:

CASE SENSITIVE ORDER : [Florence, Great Barrier Reef, Tokyo, bora bora, cusco, denmark]
CASE INSENSITIVE ORDER : [bora bora, cusco, denmark, Florence, Great Barrier Reef, Tokyo]