Arrays
- toString(type[] arr):将数组转换为字符串展现
- sort(type[] arr):将数组按照升序排列
- copyOfRange(type[], start, end):复制数组的一部分或者整个数组
- binarySearch(type[], start, end, char):在数组索引范围内用二分查找法查找字符串,返回字符下标,没有返回-1
- fill(type[], char):将数组的值设为char
- equals(typeA[], typeB[]):判断两个数组是否相同
数组方法
String[] stringArray = { "a", "b", "c", "d", "e" };
boolean b = Arrays.asList(stringArray).contains("a");
// true
System.out.println(b);
Date
/*
* 时间转换为时间字符串
*/
public static String date2string(Date time, String format) {
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.format(time);
}
public static Date string2time(String timeStr, String format) throws ParseException {
SimpleDateFormat sdf = new SimpleDateFormat(format);
return sdf.parse(timeStr);
}
Calendar
- public static Calendar getInstance() //获取日期对象
- public int get(int field) //获取时间字段值,年,月,日,时,分,秒
- public void add(int field,int amount) //指定字段增长某
- public final void set(int field,int value)//设置指定字段的值
- public final Date getTime() //获取该日历对象转成的日期对象
System
- currentTimeMillis():获取当前系统时间的毫秒值
- exit(int status) 用来结束正在运行的Java程序。参数传入一个数字便可。一般传入0记为正常状态,其余为异常状态
- gc() 用来运行JVM中的垃圾回收器,完成内存中垃圾的清除。
- getProperty(String key) 用来获取指定键(字符串名称)中所记录的系统属性信息
Math
- abs
- ceil
- floor
- max
- min
- round
- random