int类型数组
package daysreplace;
import java.util.Arrays;
public class Test {
public static void main(String[] args) {
int[] arrays={38,24,42,56,22,44};
//直接输出数组名称就是内存地址
System.out.println(arrays);
//Arrays.toString()会将数组内容转成字符串形式
System.out.println(Arrays.toString(arrays));
Arrays.sort(arrays);
System.out.println("排序后结果"+arrays);
System.out.println("排序后结果从小到大"+Arrays.toString(arrays));
System.out.println("排序后的结果从大到小");
for (int i = arrays.length-1; i >=0 ; i--) {
System.out.println(arrays[i]);
}
// System.out.println("排序后的结果从大到小"+Arrays.toString(arrays));
}
}
char类型数组
package daysreplace;
import java.util.Arrays;
public class Test {
public static void main(String[] args) {
char[] ch={'a','c','b','m'};
Arrays.sort(ch);
System.out.println(Arrays.toString(ch));
}
}