'allo.
You got two things mixed up here.
1 - Methods that throw exceptions have that 'throws' clause. This states that this method might throw a non-runtime exception, and that alerts wrapping code (code that uses this method) that it should wrap the method call with a try..catch sequence.
If you ommit this 'throws' clause - you will not signal that an exception might be thrown outside the method. This, in the
Java spec, says one of two things: you either never throw an exception from this method (i.e. all you do is very clean and simple) or -any exception that might be raised in this method will be handled inside the method itself (in try..catch).
2- Now, about the type of Exception - I agree that you could write 'throws Exception' and leave it all up to the wrapping code, but that's not very OO. When you use 'throws' you have a contract - and you want to follow this contract. Think of coding the other way around - suppose you have an existing code that uses your (unwritten yet) method, and checks for
IllegalStateException.
Now, you write your method, and declare it as 'throws Exception' - The existing wrapping code will not compile now, because you said 'yeah, I can throw an IllegalStateException, but many others as well.'.
Helpful?
Nimo.