How would I manually throw an IndexOutOfBoundsException
in Java and optionally print a message?
You simply:
throw new IndexOutOfBoundsException("your message goes here");
If you need to print that message, do so from where you catch the exception. (You can reach the message with the getMessage()
method.)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With