-
Junior Member
java forum
hi firiends what is difference between throw and throws keywords in java exception handling
-
Junior Member
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.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules