我有一段 Java 代码,我不确定为什么我没有从中得到任何结果。代码如下:
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"));
}
}
if..else 条件完美运行,如果有记录,系统确实会进入 else 系统。但是,它不会进入 while 循环。我错过了什么?
最佳答案
您已经调用了一次next()
(在if
中)。我认为最简单的解决方案是将 else
更改为 do-while
,例如,
do {
// -- Show that there are record
System.out.println(ReminderList.getString("ReminderID"));
} while (ReminderList.next());
关于Java - 无法读取包含在 if else 语句中的记录集,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/27738779/