我在IDE中收到以下提示:“取消引用可能为空的指针”:
double tmpTermCoeff = tmpTerm.getCoeff();
我不确定如何使用以下代码解决此警告。如果我将“ null”替换为“ new Term()”,它可以工作,但是由于我在while循环之后立即创建它而感到多余或错误。
while(!tmpList.isEmpty()){
Iterator<Term> iter = tmpList.iterator();
Term tmpTerm = null;
if(iter.hasNext()){
tmpTerm = new Term(iter.next());
iter.remove();
}
while(iter.hasNext()){
if(condition){
double tmpTermCoeff = tmpTerm.getCoeff();
iter.remove();
}
}
simpleP.addTerm(tmpTerm);
}
答案 0 :(得分:0)
<button className="btn btn-primary" onClick={() => {
let newNote = { id: 0, name: this.name, description: this.description, author_id: this.author_id, author: this.author }
noteContainer.addNote(newNote)
}
}>
Save
</button>