import java.util.LinkedList;标签:LinkedList,linkedList,System,linkedList1,println,out From: https://www.cnblogs.com/wxyhh/p/17443510.html
import java.util.List;
public class LinkedL {
public static void main(String[] args) {
//LinkedList
//1--创建对象
LinkedList linkedList=new LinkedList();
//2--调用方法
//add(是list的子类所以说还是有序,并且可以重复的)
linkedList.add("张三");
linkedList.add(123);
linkedList.addFirst("李四");//指定从第一位置开始添加
linkedList.addLast("吴大");
System.out.println(linkedList);
LinkedList linkedList1=new LinkedList(linkedList);
System.out.println(linkedList1);
//remove
linkedList1.remove(1);
linkedList1.remove("张三");
linkedList1.removeFirst();
System.out.println(linkedList1);
System.out.println("00000000000");
//set
linkedList1.set(0,"张三");//前面是指定的位置,后面是要修改成的内容
//get
System.out.println(linkedList1.get(1));//下标对应的内容
System.out.println(linkedList1.getFirst());
System.out.println(linkedList1.getLast());//获取最后位置的内容
System.out.println(linkedList1.size());
System.out.println(linkedList1.isEmpty());
System.out.println(linkedList1.contains("吴大"));
}
}