Well, there are many throw exceptions, but here's how you make an exception:
throw new IllegalArgumentException("INVALID");
Also yes, you can create your own custom exceptions.
Edit: Also note the exceptions. When you throw an exception (like the one above), and you find the exception: the String that you provide in the exception can be accessed by the getMessage() method.
try{ methodThatThrowsException(); }catch(IllegalArgumentException e) { e.getMessage(); }
RMT Aug 04 2018-11-11T00: 00Z
source share