Hi Stack Overflow community ^_^
Basically, I am working with Stacks and converting from Infix to Postfix equations. This is the error message showing on screen when I am trying to compile the Stack class:
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
I am having real troubles trying to figure out this error but sadly I don't have a clue of what might be the problem. If I knew a little better I could have provided you with more info.
Thanks in advance for any comments and help!
Update: Here is my class...
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();
}
public int lenghtIs()
{
return list.lengthIs();
}
public T peek()
{
return list.returnFirstNode();
}
public void print()
{
list.print();
}
public boolean isEmpty()
{
return list.isEmpty();
}
}