当前位置: 代码迷 >> J2SE >> 初学者求教,为什么只输出了A
  详细解决方案

初学者求教,为什么只输出了A

热度:61   发布时间:2016-04-24 00:51:43.0
菜鸟求教,为什么只输出了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..而且,单的链表就可以了
  相关解决方案