第 41 和 42 行,
push(stack,br); and pop(stack);
我收到错误“类型中的方法不适用” 有什么想法导致它发生,以及如何避免将来这样做吗? 谢谢
public class Reverse2
{
public static void push(Stack<String> stack,BufferedReader br) throws IOException
{
String line = br.readLine();
while ( line != null)
{
stack.push(line);
line = br.readLine();
}
}
public static void pop(Stack<String> stack)
{
while (stack.isEmpty() == false)
System.out.print(stack.pop());
}
public static void main(String args[]) throws IOException
{
stack stack = new stack();
Scanner K = new Scanner(System.in);
String filename;
System.out.print("Enter filename ");
filename = K.next();
BufferedReader br = new BufferedReader(new FileReader(filename));
push(stack,br);
pop(stack);
br.close();
}
}
最佳答案
你有:
stack stack = new stack()
什么时候应该是:
Stack<String> stack = new Stack<String>();
关于java - 类型中的方法不适用,但传递了正确数量的变量(?),我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/58845967/