sort array on string code example
Example 1: How to sort a string array in java
import java.util.Arrays;
public class JavaArraySortMethod
{
public static void main(String[] args)
{
String[] strGiven = {"Great Barrier Reef", "Paris", "borabora", "Florence","tokyo", "Cusco"};
Arrays.sort(strGiven);
System.out.println("Output(case sensitive) : " + Arrays.toString(strGiven));
}
}
Example 2: sort a string array java
String[] myArray = {"JavaFX", "HBase", "OpenCV", "Java", "Hadoop","Neo4j"};
Arrays.sort(myArray);
System.out.println(Arrays.toString(myArray));