Cursor.hasNext throws java.util.NoSuchElementException
问题 public String ForDate(String date) { MongoCursor<Document> cursor = collection.find(eq("date", date)).iterator(); basicb b = new basicb(); while (cursor.hasNext()) { b.setDepartament(cursor.next().getString("departament")); b.setText(cursor.next().getString("text")); b.setTitle(cursor.next().getString("title")); lista.add(b); } } I just want to do object from mongodb information but when I do this method get make some object but always return that errorjava.util.NoSuchElementException. 回答1: