jshell> class WrongInputException extends Exception {
...> public String toString() {
...> return "ERROR!!";
...> }
...> }
jshell> try {
...> ;
...> }
...> catch (ArithmeticException a) {
...> ;
...> } // <------- compiles fine here
jshell> try {
...> ; // if I use throw new WrongInputException() it would have compiled perfectly
...> }
...> catch (WrongInputException a) {
...> ;
...> }
| Error:
| exception WrongInputException is never thrown in body of corresponding try statement
| catch (WrongInputException a) {
| ^------------------------------...
jshell> class WrongInputException extends Exception {
...> public String toString() {
...> return "ERROR!!";
...> }
...> }
jshell> try {
...> ;
...> }
...> catch (ArithmeticException a) {
...> ;
...> } // <------- compiles fine here
jshell> try {
...> ; // if I use throw new WrongInputException() it would have compiled perfectly
...> }
...> catch (WrongInputException a) {
...> ;
...> }
| Error:
| exception WrongInputException is never thrown in body of corresponding try statement
| catch (WrongInputException a) {
| ^------------------------------...