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

Solutions on MaxInterview for sort string array in case insensitive order and case sensitive order java by the best coders in the world

showing results for - "sort string array in case insensitive order and case sensitive order java"
Kelsie
31 Sep 2020
1import java.util.Arrays;
2public class SortStringArrayDemo
3{
4   public static void main(String[] args) 
5   {
6      String[] fruits = new String[5];
7      fruits[0] = "Mango";
8      fruits[1] = "cherries";
9      fruits[2] = "Apple";
10      fruits[3] = "lychee ";
11      fruits[4] = "Elderberry";
12      Arrays.sort(fruits);
13      System.out.println("CASE SENSITIVE ORDER : ");
14      System.out.println(Arrays.toString(fruits));
15      Arrays.sort(fruits, String.CASE_INSENSITIVE_ORDER);
16      System.out.println("CASE INSENSITIVE ORDER : ");
17      System.out.println(Arrays.toString(fruits));
18   }
19}