eclipse - cursor.next() always returns "java.util.NoSuchElementException" -
i writing program in java reads query results mongodb. below code (which gives exception): if(output != null){ basicdbobject wherequery = new basicdbobject(); dbcursor cursor = null; (dbobject obj : output.results()) { string userid = obj.get("userid").tostring(); wherequery.put("user_id", userid); cursor = users.find(wherequery); system.out.println(cursor.tostring()); system.out.println("this user name tweeted "+ cursor.next()); } } when run code, first value of cursor gets printed using sysout statement in last line, second value comes 'for' loop results in exception. wonder why? the sysout statement before cursor.next() prints current value in cursor time, placed there verify whether cursor has va...