how to sort an array of strings alphabetically in java code example
Example: java sort string characters alphabetically
// java sort string characters alphabetically
import java.util.Arrays;
public class CharactersAlphabetically
{
public static void main(String[] args)
{
String strInput = "flowerbrackets";
// converting string to char array
char[] ch = strInput.toCharArray();
// sorting char array
Arrays.sort(ch);
// converting char array to string
String strSorted = String.valueOf(ch);
System.out.println("sort string characters alphabetically: " + strSorted);
}
}