1)字符串变成字符数组。
2)对数组排序,选择,冒泡,Arrays.sort(str.toCharArray());
3)将排序后的数组变成字符串。
public void testSort() {
String str = "abcwerthelloyuiodef";
char[] arr = str.toCharArray();
Arrays.sort(arr);
String newStr = new String(arr);
System.out.println(newStr);
}
最后
以上就是故意水池最近收集整理的关于对字符串中字符进行自然顺序排序。“abcwerthelloyuiodef”的全部内容,更多相关对字符串中字符进行自然顺序排序内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复