一般常用api有Math类,System,Object类型,Arrays类,包装类型,Date时间类,SimpleDateFormat时间格式,Calendar日历类.
math类:
Math.abs(int类型);返回绝对类型 如Math.abs(-88);返回类型就是88
Math.ceil(double类型);double只要不是一个整数,返回值就是double加1的double整数, 如 Math.ceil(12.003);返回值就是13.0;
Math.floor(double类型);double只要不是一个整数,返回值就是double整数小数都不要, 如 Math.ceil(12.99);返回值就是12.0;
Math.round(double类型);返回类型是int类型就是四舍五入.如Math.round(12.5);返回13;
Math.max(int 类型,int 类型);返回两个int类型中的较大的类型.如Math.max(11,22);返回22.
Math.min(int 类型,int 类型);返回两个int类型中的较小的类型.如Math.min(11,22);返回11.
Math.pow(int类型1,int类型2);返回值是类型1的类型2次幂.如Math.pow(3,3);返回就是3^3就
是3*3*3=27.
Math.random();返回值是0到1的随机小数.
System:
System.currentTimeMillis());返回以毫秒为单位的当时时间.就是现在时间到1970年0月0日.的
毫秒值.
System.exit(int类型);关闭java虚拟机.int类型为0表示正常关闭虚拟机,int类型为不为0表示非
正常关闭虚拟机.
arrayCopy: 拷贝数组.如int[]arr={1,2,3,4}; int []arr1=new int [arr.length]; System.arraycopy(arr,0,arr1,0,arr.length);arraycopy参数要拷贝的数组,数组起始位置,目标
数组,复制的索引位置,复制长度.
Object类型:
Object是万能类.什么都可以放进去.数组,int,集合,对象.等都可以放进去.
Arrays类:
Arrays.toString(数组);数组的内容的字符串表示形式.就是 System.out.println(Arrays.toString(数组)); 打印出arr数组中的所有数.
Arrays.sort(int类型数组);有序的排序.
Arrays.equals(数组1,数组2);比较两个数组是否一样.,一样就返回true,不一样就返回false;
Arrays.binarySearch(数组,object);返回查询object在数组中的索引位置.如果没有返回负数.
包装类型:
Date时间类:
Date a=new Date();返回美国的时间类型.
SimpleDateFormat时间格式:
y年,M月,d日,H时,m分,s秒
Calendar日历类.: