嗨Stack Overflow社区^ _ ^
基本上,我正在使用Stacks并从Infix转换为Postfix方程式.当我尝试编译Stack类时,这是在屏幕上显示的错误消息:
Stack.java:5: error: type argument T#1 is not within bounds of type-variable T#2
private LinkedList<T> list;
^
where T#1,T#2 are type-variables:
T#1 extends Object declared in class Stack
T#2 extends Comparable<T#2> declared in class LinkedList
Run Code Online (Sandbox Code Playgroud)
我试图找出这个错误真的很麻烦,但遗憾的是我不知道可能是什么问题.如果我知道的更好,我可以为您提供更多信息.
在此先感谢您的任何意见和帮助!
更新:这是我的班级......
package ListPkg;
public class Stack<T> // implements Comparable<Stack>>
{
private LinkedList<T> list;
public Stack()
{
this("list");
}
public Stack(String name)
{
list = new LinkedList(name);
}
public void push(T item)
{
list.insertAtFront(item);
}
public T pop()
{
list.removeFromFront(); …Run Code Online (Sandbox Code Playgroud)