- public static void main(String[] args) {
- int[] data = { 1,2,3,4,5};
- List list = Arrays.asList(data);
- System.out.println("列表中的元素数量是:" + list.size());
- }
Java代码
- int[] data = { 1,2,3,4,5};
- List list = Arrays.asList(data);
- System.out.println("元素类型:" + list.get(0).getClass());
- System.out.println("前后是否相等:"+data.equals(list.get(0)));
Java代码
- Integer[] data = { 1,2,3,4,5};
- List list = Arrays.asList(data);
- System.out.println("列表中的元素数量是:" + list.size());
Java代码
- //枚举,声明一个星期
- enum Week{Sun,Mon, Tue, Wed,Thu,Fri,Sat}
- public static void main(String[] args) {
- //工作日
- Week[] workDays = {Week.Mon, Week.Tue, Week.Wed,Week.Thu,Week.Fri};
- //转换为列表
- List<Week> list = Arrays.asList(workDays);
- //增加周六也为工作日
- list.add(Week.Sat);