- import java.util.*;
- class LinkedListDemo{
- public static void main(String[] args){
- LinkedList link=new LinkedList();
- link.addFirst("java04");
- link.addFirst("java01");
- link.addFirst("java03");
- link.addFirst("java02");
- System.out.println(link.size());
- while(!link.isEmpty()){
- System.out.println(link.removeFirst());
- }
- System.out.println(link.size());
- }
- }
复制代码
如何获取LinkedList中的元素呢? |