日期:2014-05-20 浏览次数:20584 次
import java.util.ArrayList; public class Test { static void print(ArrayList al){ al.add(2); System.out.println(al.get(0)); System.out.println(al.get(1)); System.out.println(); al=new ArrayList(); al.add(3); al.add(4); System.out.println(al.get(0)); System.out.println(al.get(1)); System.out.println(); } public static void main(String args[]){ Test test=new Test(); ArrayList al=new ArrayList(); al.add(1); print(al); for(int i=0;i<al.size();i++){ System.out.println(al.get(i)); } System.out.println(); System.out.println(al.get(1)); System.out.println(); } }