如何使用取自另一个字符串的字母顺序字母创建一个字符串?
假设我有这样的东西
String theWord = "Hello World";
如何计算新字符串以使其看起来像"
dehllloorw
这是单词,但按字母顺序逐个字符排序。
提前致谢
最佳答案
char[] chars = theWord.toCharArray();
Arrays.sort(chars);
String newWord = new String(chars);
关于java - 使用 Java 中的字符串单词中的排序字母创建新字符串,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/6266572/