Prepare for your Next Interview
This is a discussion on java forum within the Java forums, part of the Software Development category; hi firiends what is difference between throw and throws keywords in java exception handling...
|
|||
|
Re: java forum
Hi kuklkarni,
Throws :- it is used to specify method level excetpion,to specify some statements in side a method level, when we are calling this type of methods we must handle the exceptions thrown by statements in the method. eg :- public class ThrowEeg{ void m1() throws Exception { sop(""); a= a/0; sop(a);//this line throws Exception. sop(""); //this line dose n't excute } public static void main(String arg[]) { ThrowEeg thre = new ThrowEeg(); try{ //here we call the try statement. thre.m1();//method calling here. } catch(Exception e){ sop(e); } } Throw :- it is generally use with user defined exceptions.to manually throw an exception use this key word. |
![]() |
|
| Thread Tools | |
| Display Modes | |
|
|
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| Where is Introduction forum? | thuongshoo | Suggestions & Feedback | 6 | 01-11-2008 08:01 AM |
| New to this forum | nikhil_rattan | Get Together | 8 | 01-24-2007 07:52 PM |
| regarding GD forum | vmshenoy | Suggestions & Feedback | 2 | 01-09-2007 01:15 AM |