JAVA中int与Integer的相互转换

①int转Integer

int a = 5;

Integer A = new Integer(a);

Integer A = Integer.valueOf(a);

②Integer转int

Integer A = new Integer(5);

int a = A.intValue();

③int[] 转Integer[]

int[] arr = {1,2,3,4,5,6,7,8,9,10};

Integer[] Integers = new Integer[arr.length];

for(int i=0;i

    Integers[i] = arr[i];

}

④Integer[]转int[]

Interger[] Integers = new Integer[]{3,32,321};

for(int i=0;i

    arr[i] = Integer[i].intValue();

}

你可能感兴趣的:(Java程序设计--笔记,Java基础)