將基本類型也轉換成了對象以對其功能擴展java
javaWeb接受到的數據都是以String類型的,怎麼把String轉換爲int數組
|字節 | 整型 | 字符 | 布爾|dom
| ---- | ------- | ------ | ------- |ide
| Byte | Integer | String | Boolean |函數
數字格式的字符串工具
*Integer.parseInt("12") NumberFormatException操作系統
任何類型轉換爲String ,只須要鏈接空串" "code
使用Integer中的靜態方法toString()orm
利用Integer的構造方法將String轉換爲int類型對象
Integer in = new Integer("100"); int in = in.valueOf();
System.out.println(Integer.MAX_VALUE); System.out.println(Integer.MIN_VALUE)
Integer i = 1; //不用new Integer() System.out.println(i) //打印應用類型會調用toString(),說明咱們重寫過toString() ArrayList<int> ar = new ArrayList<int> //會報錯,由於int是基本數據類型不是對象 ArrayList<Integer> ar = new ArrayList<Integer> ar.add(1); //1是基本數據,可是自動轉換爲對象了 Integer in = null; in = in + 1; //弊端,在爲空的時候是不會自動裝箱的 //在運算的時候就會NullPointException
Integer i = 127; Integer j = 127; System.out.println(i==j);//Ture //數據在自動裝箱的時候數據沒有大於1字節,因此 Integer j = i; System.out.println(i.equals(j));//Ture
私有修飾構造函數
調用方法只能使用類名調用
public static void currentTimeMillis()
public static void exit(int status)
public static void gc()
public static Properties getPropertise()
public static void arraycopy(Object src ,int srcPos ,Object dest , int destPos, int length)
複製一個數組
src:源數組
srcPos:源數組的開始的索引
dest:複製後目標數組
destPos:目標數組起始索引
length:複製幾個
int[] src = {11,22,33,44,55,66}; int[] dest = {77,88,99,0}; System.arraycopy(src, 1, dest, 1, 2)
靜態方法工具類
random
java.util
繼承至java.lang.Object
public static void sort(array)
Arrays.sort(數組)
public static int binarySearch(array, element)
- 插入點索引 - 1
public static String toString(array)
超過lang的範圍的就是BigInteger對象
四則運算符
來完成