it is often convenient to instantiate an exception object at the time the exception has to be thrown thusa throw statement is typically written as followsthrow new exception_type(param param param - )where exception_type is the type of the exception and the param ' form the list of parameters for constructor for this exception exceptions are also thrown by the java run-time environment itself for examplethe counterpart to the example above is arrayindexoutofboundsexception if we have six-element array and ask for the ninth elementthen this exception will be thrown by the java run-time system the throws clause when method is declaredit is appropriate to specify the exceptions it might throw this convention has both functional and courteous purpose for oneit lets users know what to expect it also lets the java compiler know which exceptions to prepare for the following is an example of such method definitionpublic void goshopping(throws shoppinglisttoosmallexceptionoutofmoneyexception /method body by specifying all the exceptions that might be thrown by methodwe prepare others to be able to handle all of the exceptional cases that might arise from using this method another benefit of declaring exceptions is that we do not need to catch those exceptions in our method sometimes this is appropriate in the case where other code is responsible for causing the circumstances leading up to the exception the following illustrates an exception that is "passed through"public void getreadyforclass(throws shoppinglisttoosmallexceptionoutofmoneyexception