如果条件为假则执行if语句

时间:2020-07-25 02:23:39

标签: java spring loops if-statement

我正在尝试:如果abb.iscurrentlyy()返回true,则进入if语句,或者abb.islately()是true。

我的if语句怎么了?当我将abb.iscurrentlyy()设置为false时。 abb.islately()设置为true。为什么abb.iscurrentlyy()甚至为假,abb.iscurrentlyy()也会进入循环?

    if (abb.iscurrentlyy() || abb.islately()) {

        if (reqFiles != null) {

            for (int i = 0; i < reqFiles.length; i++) {

                Future<ExecResult> lcukv = executor.submit(worker);
                executionFutureException.add(lcukv);
            }
        }

    } else { // do if condition is false.
    }

2 个答案:

答案 0 :(得分:5)

术语$ ./bin/struct2darr dat/in5x4.csv 6 4 7 3 4 2 3 2 2 5 3 3 6 3 3 2 5 6 7 5 (||)表示,条件为真时,至少一个子条件必须为真。

or

在现实世界中,想象走进一家冰淇淋店。你喜欢草莓冰淇淋。您还喜欢巧克力冰淇淋。您讨厌其他所有口味。如果商店至少有其中一种口味,那么您会感到很开心。

您的代码类似于上面的示例。另一方面,如果在其中一个条件为真而另一个条件为假时希望为假,请使用boolean condition1 = true; boolean condition2 = false; if(condition1 || condition2) { System.out.println("One or both conditions were true"); } else { System.out.println("Both conditions were false"); } (&&)。

and

在这种情况下,冰淇淋店必须同时拥有自己喜欢的两种口味,以便让您开心。

认为boolean condition1 = true; boolean condition2 = false; if(condition1 && condition2) { System.out.println("Both conditions were true"); } else { System.out.println("At least one condition was false"); } 更为宽容:“我可以使这个或那个为真。” or听起来很包容,但实际上更具有排他性:“我必须拥有且必须是真实的。”

答案 1 :(得分:2)

在您的代码中, Future<void> refreshRestaurant() async { var _id = restaurant.id; restaurant = new Restaurant(); reviews.clear(); ureviews.clear(); listenForRestaurant(id: _id, message: S.of(context).restaurant_refreshed_successfuly); listenForRestaurantReviews(id: _id); listenForUserRestaurantReviews(id: _id); } abb.isCurrentlyy()都必须为false才能进入循环。 abb.islately()用作逻辑或。这意味着如果值之一为true,则语句的评估结果为True。我建议您针对这两个条件编写单独的if循环。