throws --> throws declare that it throws the exception to
the calling method.
throw --> it is surrounded by the try catch block actually
it does the work, of throwing the exception.
public void testMethod() throws BusinessException
// catch all the exceptions and provide some meaningful
throw BusinessException("An error occured while
trying to connect to DB");
Method capable of raising an exception but not handling the
same. i.e to say no Try Catch block is implemented in the
Method, to handle the exception.
The callers should create the Try Catch Block to safeguard
against the exception.
If the above is not followed it would result in Compilation
The method that raises the exception also handles the same
in its Catch block.
If unhandled the exception can also be handles by the
Callers Try Catch Block.
Hope this makes sense.
In Throws, what ever the exception you are declaring are
handle by JVM. If it is a user defined exception in throws
block, JVM doesn't know when to throw that exception. For
this purpose we use Throw for a certain conditions/logic to
throw these user defined exceptions.
I need some details about an employee. i have only the
employee id in my presentation layer(JSP).I entered that ID
and click "Show Details" Button. Question is how the JSP
pass that id to Controller layer and DAO and what mechanism
we are using to retrive data from DB and how the data
passed to JSP as a Output. Please explain in detail.
How to excute - Interface - Inner class- method
can any one tell how to execute/ call this main method
public interface abc
static int i=0; void dd();
public static void main(String a1)