赞
踩
public static void main(String[] args) { List<Integer> list = new ArrayList<>(); list.add(0); list.add(1); list.add(2); list.add(3); list.add(4); System.out.println("修改前:"+list); Collections.swap(list,0,1); System.out.println("修改后:"+list); Collections.sort(list); //排序list System.out.println("排序后:"+list); System.out.println( "最大:"+Collections.max(list)); System.out.println("最小:"+Collections.min(list)); System.out.println("一、--------------"); for (int i = 0; i < list.size(); i++) { System.out.println(list.get(i)); } System.out.println("二、--------------"); for (Integer i:list){ System.out.println(i); } System.out.println("三、--------------"); Iterator<Integer> it = list.iterator(); while (it.hasNext()){ Integer next= it.next(); System.out.println(next); } }
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。