java - 检查 IF 条件然后将其绕过到 ELSE
问题描述
我有一个 IF ELSE 条件语句块。假设这是我的代码
如何在不更改A 或 B的情况下到达代码的 isTrue 的 IF ELSE?我试过return true但它不会返回,因为它在一个方法中。有什么关键字可以这样做吗?
public void test() {
if (text1.equals("") {
//Output error message
} else if (text2.equals("") {
//Ouput error message
.
.
.
} else if (A!= null && (A > B)) {
//GO TO ELSE condition without changing the A or B
} else { if (isTrue){} }
}
解决方案
从其他条件中取出最后一个条件:
public void test() {
if (text1.equals("") {
//Output error message
} else if (text2.equals("") {
//Ouput error message
} else if (A!= null && (A > B)) {
//GO TO ELSE condition without changing the A or B
}
if (isTrue){ }
}
推荐阅读
- python - unicode dict 键的令人惊讶的行为
- docker - 无法在 Windows 上启动 docker
- mysql - mysql中的Concat 2查询以获取库存报告
- ios - iOS 图标构建错误
- validation - 如何在inputtext里面设置required = true
- vb.net - 二维数组到Visual Basic中的数组
- c# - 如何将 byte[] 转换为模型
- laravel - file_get_contents():SSL 操作失败,代码为 1。OpenSSL 错误消息
- mysql - Laravel 从查询中检索列值给出错误
- c# - 来自 c# 富应用程序的可信数据