1、数组工具类Arrays
/*
* tostring()
* sort()
* */
public static void main(String[] args) {
int [] array = {12,413,3};
String str = java.util.Arrays.toString(array);
System.out.println(str);
java.util.Arrays.sort(array);
System.out.println(java.util.Arrays.toString(array));
}
2、练习题
public static void main(String[] args) {
String str = "dfgdsdkasiuytqwrds";
char [] charArr = str.toCharArray();
System.out.println(Arrays.toString(charArr));
//[d, f, g, d, s, d, k, a, s, i, u, y, t, q, w, r, d, s]
Arrays.sort(charArr);
System.out.println(Arrays.toString(charArr));
//[a, d, d, d, d, f, g, i, k, q, r, s, s, s, t, u, w, y]
//反向输出
//ywutsssrqkigfdddda
for (int i = 0; i < charArr.length; i++) {
char cha = charArr[charArr.length-1-i];
System.out.print(cha);
}
}
二、Math
public static void main(String[] args) {
System.out.println(Math.abs(3.45));//绝对值
System.out.println(Math.ceil(3.45));//向上取整
System.out.println(Math.floor(3.45));//向下取整
System.out.println(Math.round(3.45));//四舍五入
}