packagecom.czl;importjava.util.ArrayList;importjava.util.List;//Alt+Enter导入包publicclassMain{publicstaticvoidmain(String[] args)throwsException{List<Integer> list =newArrayList<>();for(int i =0;i<4;i++)
list.add(i);for(int i =0;i<4;i++)
list.set(i,list.get(i)+10);System.out.println(list);//[10, 11, 12, 13]System.out.println(list.get(1));//11}}
栈(类)
importjava.util.ArrayList;importjava.util.List;importjava.util.Stack;//Alt+Enter导入包publicclassMain{publicstaticvoidmain(String[] args)throwsException{//PS:不能写基本类型 写成对象 ,int的对象是IntergerList<Integer> list =newArrayList<>();//定义链表Stack<Integer> stack =newStack<>();//定义栈for(int i=0;i<4;i++)
stack.push(i);System.out.println(stack.pop());//3}}