string array sorting in java code example
Example 1: sort string java
import java.util.Arrays;
public class Test
{
public static void main(String[] args)
{
String original = "edcba";
char[] chars = original.toCharArray();
Arrays.sort(chars);
String sorted = new String(chars);
System.out.println(sorted);
}
}
Example 2: sort a string array java
String[] myArray = {"JavaFX", "HBase", "OpenCV", "Java", "Hadoop","Neo4j"};
Arrays.sort(myArray);
System.out.println(Arrays.toString(myArray));