为什么我得到一个错误(顶部方法和isempty方法)说找不到符号



我写了这段代码,但在isEmpty方法上出错,说找不到符号?

import java.io.*;
import java.util.Scanner;
public class ITDLinkedStack{
public int peek() 
{ 
 if (isEmpty()) // this is where i get the error
 throw new RuntimeException("Peek attempted on empty stack");
 else
return top.data;
}
   }

在您发布的这段代码中,您排除了代码的其余部分。如果你把它添加到你的代码中,你的行就可以工作了!

 if (isEmpty()) // this is where i get the error
 throw new RuntimeException("Peek attempted on empty stack");
 else
return top.data;

相关内容

最新更新