randomizertech randomizertech - 1 year ago 172
Java Question

Creating new String with sorted letters from a String word in Java

How do I create a String with alphabetical order letters taken from another String?

Let's say I have something like this

String theWord = "Hello World";

How do I compute the new String to make it look like"


Which is theWord but sorted character by character in alphabetical order.

Thanks in advance

Answer Source
char[] chars = theWord.toCharArray();
String newWord = new String(chars);
Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download