结论: 如果判断条件非法,直接抛出异常
throw new IllegalArgumentException("Wrong!");
下面直接截取详细内容:
If the program ever executes a statement like:
throw new ???Exception("… message …");
Java stops the program and signals the error through the constructed instance of the ???Exception (where the ??? are replaced by the name of whichever particular exception is desired). For our purposes, this will simply terminate the program and print the given error message.