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

Java 3D LWJGL collision -

spring - SubProtocolWebSocketHandler - No handlers -

methods - python can't use function in submodule -