配列リストが空の場合、このコードはエラーを返します。エラーを回避し、空の場合は null を返すためにコードを追加する必要があります。ありがとう
public Comment findMostHelpfulComment()
{
Iterator<Comment> it = comments.iterator();
Comment best = it.next();
while(it.hasNext())
{
Comment current = it.next();
if(current.getVoteCount() > best.getVoteCount()) {
best = current;
}
}
return best;
}