how to sort strings alphabetically in java from a stack 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);
}
}