Last active
December 3, 2017 16:40
-
-
Save ShmuelMofrad/97297eab2278ff53497cc892924bb90e to your computer and use it in GitHub Desktop.
IllegalStateException
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class IllegalStateExceptionInWhile { | |
public static void main(String[] args) { | |
seeMore(); | |
run(); | |
iamNotWorking(); | |
} | |
static void run() { | |
int counter = 0; | |
while (true) { | |
counter++; | |
System.out.println("counter: " + counter); | |
if (counter >= 8) { | |
throw new IllegalStateException("it is inappropriate time!"); | |
} | |
} | |
} | |
private static void iamNotWorking() { | |
System.out.println("I'm not working"); | |
} | |
private static void seeMore() { | |
System.out.println("\n`public class IllegalStateException`\r\n" + "`extends RuntimeException`\n" | |
+ "Signals that a method has been invoked at an illegal" | |
+ " or inappropriate time. In other words, the Java environment or Java application" | |
+ " is not in an appropriate state for the requested operation."); | |
System.out.println("\n\n[ Read more ]\n[ https://docs.oracle.com/javase" | |
+ "/8/docs/api/java/lang/IllegalStateException.html ]\n"); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment