LinkedList-插入一个元素

import java.util.LinkedList;

public class InsertAnObject {

public static void main(String[] args) {
    // TODO Auto-generated method stub
    LinkedList officers = new LinkedList();
    officers.add("Blake");
    officers.add("Burns");
    officers.add("Jack");
    officers.add("P");
    officers.add("Tom");
    officers.add(2, "new");
    for (String s : officers)
       System.out.println(s);
}

}
Console:
Blake
Burns
new
Jack
P
Tom

你可能感兴趣的:(LinkedList-插入一个元素)