here what am wandering is, in line 1 of this code "throws Exception" what exactly does?
It gave the responsibility to the caller of the function, that, this method, can throws an Exception, You [Caller] have to handle it.
And, In your case, It's a RuntimeException
will be thrown from that method, so, no need to declare the method with Exception. That's why even though if you removed that throws Exception part, It works.
If the method will throw a checked Exception, and if you don't handle it inside the method itself, you have declare to throw that exception in the method signature.