public class CircularSLList<T>
{
protected class SLNode<T>
{
public T element = null;
public SLNode<T> next = null;
}
protected SLNode<T> tail = null;
protected SLNode<T> currentNode = null;
int size;
@Override
public String toString()
{
SLNode<T> current = tail;
if(tail == null)
return "<Empty List>";
else
{
String s = "<";
for(int i = -1; i < size; i++, current=current.next)
{
if(i > -1)
s = s.concat(current.element.toString() + " ");
}
s = s.concat(">");
s = s.concat(" tail = " + tail.element.toString());
s = s.concat("; current = " + currentNode.element.toString());
return s;
}
}
public T get()
{
return null;
}
public T find(T element)
{
return null;
}
public void addToTail(T element)
{
if (isEmpty())
{
tail = new SLNode<T>(element);
tail.next = tail;
}
else
{
//tail.next = new SLNode<T>(element,tail.next);
//tail = tail.next;
}
}
public void addToHead(T element)
{
}
public T removeFromTail()
{
return null;
}
public T removeFromHead()
{
return null;
}
public boolean isEmpty()
{
return (tail == null);
}
}
Hi I'm new to Java and can't figure out how to fix this compile error.
error: constructor SLNode in class CircularSLList<T#1>.SLNode<T#2> cannot be applied to given types;
tail = new SLNode<T>(element);
^
required: no arguments
found: T#1
reason: actual and formal argument lists differ in length
where T#1,T#2 are type-variables:
T#1 extends Object declared in class CircularSLList
T#2 extends Object declared in class CircularSLList.SLNode
1 error

New Topic/Question
Reply



MultiQuote





|