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