简体   繁体   中英

Checking 1st if condition and then 2nd

Is there a way to put a check in for loop where 1st loop only checks if abb.iscurrently() and if its true go inside the block and in 2nd loop only checks abb.islately() avoid checking abb.iscurrently() ? My Current code.

 for (){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.
    }
  }

Use Continue; , to skip the rest of the steps in the loop.

I am not sure why someone wants to do that, But this logic should work.

boolean flag = true;

for (){(flag && if (abb.iscurrentlyy()) || abb.islately()) {
    flag = false; // this will execute everytime
    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.
}}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM