java.util.Arrays是一个与数组相关的工具类,里面提供了大量静态方法,用来实现数组常见操作
public static String toString(数组):将参数数组变成字符串[元素1,元素2,元素3…]
int[] intArray={10,20,30};
将int数组按照默认格式变成字符串
String intstr=Arrays.toString(intArrray);
String–>数组,用toCharArray
char[] chars=str.toCharArray()
public static void sort()按照默认升序(小到大)对数组元素排序。
Arrays.sort(intArray)
sout(Arrays.toString(intArray))
sort方法如果是自定义类型,那么这个自定义的类需要有Comparable或者Comparator接口的支持
java.util.Math类
public static double abs(double num)获取绝对值
public static double ceil(double num)向上取整
public static double floor(double num)向下取整
public static long round(double num)四舍五入,不带小数点
如sout(Math.abs(3.14));
Math.PI代表近似圆周率