throws or try/catch?

Is there any difference between using throws or try/catch to handle exceptions?
[86 byte] By [lokpesta] at [2007-10-3 5:08:08]
# 1
What is the difference between throws and try/catch?
mahalakshmi@jallipallia at 2007-7-14 23:14:13 > top of Java-index,Java Mobility Forums,Consumer and Commerce...
# 2

I think the difference betwteen the two is the way the exceptions are handle.

When using "throws" you must create a Exception class that must perform the actions needed when the exception is encountered. Then the function that can throw the exception must be accordingly declared :

public somefunction() throws Exception

And inside the function :

if (exceptionCondition=true)

throw new Exception

When uisng try/catch the actions that msut be performed when the exception is encountered are written inside the function.

try

{

//

}

catch (Exception e)

{

//handling exception...

}

ticus_ionuta at 2007-7-14 23:14:13 > top of Java-index,Java Mobility Forums,Consumer and Commerce...