I have a piece of java code that I am not sure as to why I am not getting any results from it. The code goes as such:
if (!ReminderList.next()) {
-- Show that there are no records available
} else {
while (ReminderList.next(){
-- Show that there are record
System.out.println(ReminderList.getString("ReminderID"));
}
}
The if..else condition works perfectly and if there are records, the system does enter the else system. However, it does not enter the while loop. What am I missing?
You have already called next()
once (in the if
). I think the easiest solution is to change the else
to a do-while
like,
do {
// -- Show that there are record
System.out.println(ReminderList.getString("ReminderID"));
} while (ReminderList.next());