这个是我的代码,楼主你的26行构造函数的处理上,有点问题- package wjd.demo01;
- import java.util.LinkedList;
- public class LinkedDemo {
- public static void main(String[] args) {
- Queue q = new Queue();
- q.my_add("a");
- q.my_add("b");
- q.my_add("c");
- while(!(q.isNull())){
- System.out.println(q.myGet_1());
- }
- }
-
- }
- class Queue{
- LinkedList<String> ll = new LinkedList<String>();
- public void my_add(String s){
- ll.addFirst(s);
- }
- public String myGet_1(){
- return ll.removeFirst();
- }
- public String myGet_2(){
- return ll.removeLast();
- }
- public boolean isNull(){
- return ll.isEmpty();
- }
- }
复制代码 |