[Solved] Java, Exception kinda [closed]


To create an Exception in Java, you could do something like this:

class GameException extends Exception {
 GameException() {
  super();
 }
 GameException(String msg) {
  super(msg);
 }
 GameException(String msg, Throwable cause) {
  super(msg, cause);
 }
 GameException(Throwable cause) {
  super(cause);
 }
}

To use this Exception, you can do the following:

if(!checkNumbers(num1, num2)) throw new GameException();

Where checkNumbers() is your method on seeing if your two input numbers are acceptable with your requirements.

4

solved Java, Exception kinda [closed]