这是if语句是怎么写的如果声明没有被读取
//Check and see if current is less than the next character.
if (node.thisChar().charAt(0) < current.thisChar().charAt(0))
{
temp = current;
previous = node;
node.next = current;
System.out.println("Its in here");
break;
}// end if
previous = current;
current = current.next;
//what was empty at the end of the list now has a new node being linked.
System.out.println(current.thisChar().charAt(0) + " This is the current");
System.out.println(node.thisChar().charAt(0) + " This is the new character");
System.out.println("Character " + node.thisChar() + " has been added");
问题与,突出if语句。例如,如果节点字母'd'
小于当前字母'f'
,if语句将最终被跳过,导致未排序的列表。放置在if语句中的输出永远不会到达。奇怪的是,我的输出将如何显示thisChar().CharAt()
(thisChar
只是返回字符,它是String
类型)的字符;表明这些陈述正在起作用。除非问题出在String
类型的变量上,否则我不知道if语句是怎么回事。任何建议将被认真考虑。
小问题,如此庞大的代码张贴 – Joe
我会编辑它 – GemToughy
如果“节点”小于“当前”,则您的条件为真。如果你想在这种情况下跳过*,你必须反转条件。 –