简体   繁体   中英

how can i fix the cannot find symbol error

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: error: cannot find symbol

  return super.size(); ^ 

symbol: method size() 1 error

Please check the fixed solution:

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();
  }
}

将此添加到类的imports部分:

import java.util.LinkedList;

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM