0

Throw in java help

does throw in java only works with "if else"?all the example i found is with "if else".could it be done without them?

4th Nov 2017, 3:50 AM
oyl
4 Answers
0
yes it can be done,but most of the time u want to throw an exception if some condition fails
4th Nov 2017, 5:12 AM
Haileyesus Shitalem
Haileyesus Shitalem - avatar
0
how to use throw for arrayindexoutofboundsexception?
4th Nov 2017, 7:06 AM
oyl
0
Why I you want throw that? That's what Arrays do automatically. But you can write anywhere in your code : throw new ArrayIndexOutOfBoundsException() ;
4th Nov 2017, 7:31 AM
1of3
1of3 - avatar
0
@1of3 i just learned about throw ytd.im just playing around with the code haha.i have figured out now https://code.sololearn.com/cwXucXgb8QGQ/?ref=app
4th Nov 2017, 7:36 AM
oyl