-
java Arrays.asList的用法
-
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();
-
}
-
}
-
相关阅读:
4.14打印特殊图案
4.13十进制/二进制转换器
4.12程序运行时间
4.11 计算文件的大小
4.10文件的读写
4.9位运算
CyclicBarrier
tar 命令
MySQL 常用函数介绍
mysql 表转 java 实体 sql
-
原文地址:https://www.cnblogs.com/lechance/p/4373181.html
Copyright © 2020-2023
润新知