提示:您可在线编辑运行本教程的实例 - 运行实例,去试试!
使用ListIterator向ArrayList添加或插入元素
/* from nowjava*/ import java.util.ListIterator; import java.util.ArrayList; public class Main { public static void main(String[] args) { //create an object of ArrayList ArrayList aList = new ArrayList(); //Add elements to ArrayList object aList.add("1"); aList.add("2"); /** 时 代 Java - nowjava.com **/ aList.add("3"); aList.add("4"); aList.add("5"); //Get an object of ListIterator using listIterator() method ListIterator listIterator = aList.listIterator(); listIterator.next(); //Add an element listIterator.add("Added Element"); System.out.println(