java - Run one of two for loops -


suppose had 2 loops, each contains if , else statement, want work if first forloop achieved break , not run second loop. simple solution, help.

the aim of program read user input , iterate on int given, if user doesn't input int value iterate on 100.

as code working except doing both loops, want 1 or other.

package coreprog;    ...         (...){          ...          if (...) {            ...           }        else          system.out.println(...);       }           (...){          ...          if (...) {            ...           }        else          system.out.println(...); 

keep boolean flag inside first loop , make true before break.based on whatever want do. example :-

boolean firstconditionachieved= false;   (...){          ...          if (...) {            firstconditionachieved = true;            ...           }        else          system.out.println(...);       }  

second loop :-

if(!firstconditionachieved){ ......   } 

Comments

Popular posts from this blog

angularjs - Redirect to a new template in angular js -

Oracle SQL. How to select specific IDs where value of columns specify criteria? -

Desktop Launcher for Python Script Starts Program in Wrong Path (Linux) -