I was about to post something similar to this.
In java you need to specify what your function can throw and if it tries to throw something that it has not specified as being able to throw, then your program won't compile.
In java you need to specify what your function can throw and if it tries to throw something that it has not specified as being able to throw, then your program won't compile.