<分区>
任务是使用 boolean 值在 linkedList 的末尾附加一个元素
/**
* Appends the specified element to the end of this list
* @param element element to add to the list
* @return true
* @throws NullPointerException when element is null
*/
我的解决方案
public boolean add(T element) {
ListNode newElement = new ListNode (element);
while (cur.link == !null) {
cur = cur.link;
cur.link = newElement(element, null);
if (cur==null) {
throw new NullPointerException;
}
}
return true;
}
在更正我的代码时需要帮助。