I want java to unify the number of continue in the for statement.

Asked 2 years ago, Updated 2 years ago, 234 views

I want to make the number of continue in the for statement one in java
I'm analyzing using sonarqube, but I get an error asking to make the number of continue one, but I don't know how to deal with it
I would appreciate it if you could let me know the implementation as follows.

 for (line:List) {

 if(isAAAA(line)){
   Execution statement;
   continue;
 }
 if(isBBB(line)){
   Execution statement;
   continue;
 }
 if(isCCC(line)){
   Execution statement;
   continue;
 }
 if(isDDD(line)){
   Execution statement;
   continue;
 }

}

Additional
Also, I would like to know about patterns that do not have execution statements.

 for (line:List) {

 if(isAAAA(line)){
   continue;
 }
 if(isBBB(line)){
   continue;
 }
 if(isCCC(line)){
   continue;
 }
 if(isDDD(line)){
   continue;
 }

}

java java8

2022-09-30 21:51

1 Answers

Please use if... else if... in this form.Continue is not required.

If the contents of if are only continue, you can combine these conditions with or into one if.


2022-09-30 21:51

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.