我正在编写一个将元素插入到链表末尾的代码。然而,在for循环结尾处没有使用分号,导致无法正确更新列表。这个分号有什么意义,它是如何影响我的代码的?
public void insertAtEnd() throws IOException {
LinkedList node=new LinkedList();
System.out.println("Enter an element");
int value=Integer.parseInt(br.readLine());
node.setData(value);
LinkedList p,q;
for(p=head; (q=p.getNext())!=null; p=q);
p.setNext(node);
}