在我的代码中:
if (id.isEmpty() || name.isEmpty()) {
warlbl.setText("Warning, Empty ID or Name Fields");
return;
}
id
和 name
是从 JTextFields
给出的 String
,
这里是否需要使用return;
?
最佳答案
是的,它可以是:
if (...) {
...
return;
}
// nothing at this point will be reached if the if-statement is entered
对比
if (...) {
...
}
// code here will still be reached!
关于java - if条件中的return语句函数,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18038127/