Hi,
Exceptions is
java are handled using the five key words:
1.
try - A try block is used to enclose a set of statements which might throw an exception
2.
catch - A catch block is used to trap the exceptions that were thrown by some try block. You would be required to write code corresponding to the
exceptional condition.
3.
throws - If a method does not handle an exception, then it may list the exception in the method signature using a "throws" clause. This would tell the
caller than the method being called throws an exception and the caller must handle it or may itself choose to throw the exception.
4.
throw - This is used to explicitly throw an exception from your code. It might be used to throw some custom exception.
5.
finally - A finally block would allow code to be executed whether or not there is an exception raised from a try block.
Even if a return statement is encountered, the finally block shall complete first.
Now onto your question: Is throwing an exception enough without writing the code for catching it ??
See, you must understand that if the main() method of your application also chooses to throw the exception instead of catching it, the exception would be caught by the default mechanism provided by the Java run time system which would print a stack trace for that exception and would cause your application to crash.
You would obviously not want that to happen. :-) So its a good practice to provide a handler and write some sort of code that you would want to be executed when an exception occurs.
By the way, in your code of the "Player" class you have thrown the Exception and also provided a try/catch to handle it. That's not required. Either handle the exception or throw it using the "throws" clause. "throws" tells the compiler that the method does not handle the exception.
Hope that clears some doubts :-)