我怎么能修复找不到符号的错误

时间:2018-04-06 05:48:48

标签: java

public class ListQueue extends LinkedList {
  public ListQueue() {
    super();
  }

  public boolean empty() {
    return isEmpty();
  }

  public void enqueue(Object item) {
    addToTail(item);
  }

  public Object dequeue() {
    return removeFromHead();
  }
  public int size(){
    return super.size();
  }
}

// class ListQueue
  

ListQueue.java:20:错误:找不到符号

  return super.size();
              ^
     

符号:方法大小()   1错误

2 个答案:

答案 0 :(得分:0)

请检查固定解决方案:

import java.util.LinkedList;

public class ListQueue extends LinkedList {
  public ListQueue() {
    super();
  }

  public boolean empty() {
    return super.isEmpty();
  }

  public void enqueue(Object item) {
    super.add(item);
  }

  public Object dequeue() {
    return super.removeFirst();
  }
  public int size(){
    return super.size();
  }
}

答案 1 :(得分:-1)

将此添加到类的导入部分:

import java.util.LinkedList;