📄 linklistdemo.java
字号:
import java.util.*;
public class LinkListDemo {
public static void main(String[] args) {
// TODO Auto-generated method stub
//create a Linked list
LinkedList l1=new LinkedList();
//add element to the linked List
l1.add("Fist");
l1.add("B");
l1.add("D");
l1.add("E");
l1.add("C");
l1.addLast("Z");
l1.addFirst("A");
l1.add(1,"A2");
System.out.println("Original content of l1"+l1);
//remove the element of the list
l1.remove("F");
l1.remove(2);
System.out.println("Content of l1 after deletion"+l1);
//Remove the fiest and last element
l1.removeFirst();
l1.removeLast();
System.out.println("Contents of delete the first and last"+l1);
//get and set a value
Object val=l1.get(2);
l1.set(2,(String)val+" changed");
System.out.println("l1 after changed"+l1);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -