菜鸟求教,为什么只输出了A?
class Node<Character>
{
Character nodevalue;
Node<Character> next, front, curr;
public Node()
{
nodevalue = null;
next = null;
front = null;
curr = null;
}
public Node(Character item)
{
nodevalue = item;
next = null;
front = null;
curr = null;
}
}
public class Test1_1
{
public static void main(String[] args)
{
Node<Character> r = new Node<Character>('M');
Node<Character> p = new Node<Character>('X');
Node<Character> q = new Node<Character>('A');
q.next=r;
r.next=p;
Node<Character> curr = q;
if(curr!= null)
{ System.out.println(curr.nodevalue);
curr = curr.next;
}
}
}
------解决方案--------------------
是把if改为while..而且,单的链表就可以了