数组通过Arrays.sort()方法实现升序和降序排列

数组

升序:Arrays.sort(arr);

降序:Arrays.sort(arr,Collections.reverseOrder());

ArrayList

升序:Collections.sort(arr);

降序:Collections.sort(arr,Collections.reverseOrder());

注:reverse()是倒序

String str = "qwewq";
String str1 =new StringBuilder(str).reverse().toString();

猜你喜欢

转载自www.cnblogs.com/YeHuan/p/10644363.html
今日推荐