-
import java.util.Arrays;
-
import java.util.List;
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
public class AsListTest {
-
-
public static void main(String[] args) {
-
-
-
-
-
int[] a_int = { 1, 2, 3, 4 };
-
-
List a_int_List = Arrays.asList(a_int);
-
foreach(a_int_List);
-
-
foreachForBase(a_int_List);
-
-
-
Integer[] a_Integer = new Integer[] { 1, 2, 3, 4 };
-
List a_Integer_List = Arrays.asList(a_Integer);
-
foreach(a_Integer_List);
-
-
-
a_Integer_List.set(0, 0);
-
foreach(a_Integer_List);
-
foreach(a_Integer);
-
-
a_Integer[0] = 5;
-
foreach(a_Integer_List);
-
foreach(a_Integer);
-
-
-
-
-
-
-
-
-
-
-
a_int[0] = 5;
-
foreachForBase(a_int_List);
-
foreach(a_int);
-
-
}
-
-
-
private static void foreach(List list) {
-
for (Object object : list) {
-
System.out.print(object + " ");
-
}
-
System.out.println();
-
-
}
-
-
private static void foreachForBase(List a_int_List) {
-
int[] _a_int = (int[]) a_int_List.get(0);
-
foreach(_a_int);
-
}
-
-
private static void foreach(int[] a_int) {
-
for (int i : a_int) {
-
System.out.print(i + " ");
-
}
-
System.out.println();
-
}
-
-
private static void foreach(Integer[] _a_Integer) {
-
for (int i : _a_Integer) {
-
System.out.print(i + " ");
-
}
-
System.out.println();
-
}
-
}
java Arrays.asList的用法
原文:http://blog.csdn.net/love_xsq/article/details/43698903