代码如下:- import java.util.*;
- class LinkedListTest
- {
- public static void main(String[] args)
- {
- DuiLie dl = new DuiLie();
- dl.myAdd("zhangsan");
- dl.myAdd("lisi");
- dl.myAdd("wangwu");
- while (dl.isNull()==false)
- {
- System.out.println(dl.myGet());
- }
-
- }
- }
- class DuiLie
- {
- LinkedList li = new LinkedList();
- public void myAdd(Object obj)
- {
- li.addFist(obj);
- }
- public Object myGet()
- {
- return li.removeLast();
- }
- public boolean isNull()
- {
- return li.isEmpty();
- }
- }
复制代码 编译时报错:li就在那里为什么提示找不到呢?
|
|