04-24-2011, 06:54 PM
Sir, I got a question , how to throw multiple exceptions form a method , and how we could know that , on a particular event , a specific kind of exception will be generated ,
for example we take input form user , and user don't write anything , what kind of the exception will be generated from here. and in the same method there is a chance of another exception like we try to open a file which don't exist , in this case there will be a total chance of two exceptions, One will be IO related, what will be the other ?????. This is just a case I think in different cases there will be different kind of exceptions. How can we know all them??
e.g.
public void method()
{
String str ;// A Null point exception
//assume user don't enter any input in the field ...there will be another exception.
str =JOptionPane.showInputDialog(null, "Please enter input. ");
dobule dAge ;
dAge= Double.parseDouble(JoptionPane.showInputDialog(null, "Please enter your age. "))//assume user enter his age in the form of String "like twenty instead of 20”. Here, another exception will be generated.
}
Now my question is how can we throw all these exceptions , how can we figure out that what kind of exception will be generated and how can we catch them ????
Thanks ….
for example we take input form user , and user don't write anything , what kind of the exception will be generated from here. and in the same method there is a chance of another exception like we try to open a file which don't exist , in this case there will be a total chance of two exceptions, One will be IO related, what will be the other ?????. This is just a case I think in different cases there will be different kind of exceptions. How can we know all them??
e.g.
public void method()
{
String str ;// A Null point exception
//assume user don't enter any input in the field ...there will be another exception.
str =JOptionPane.showInputDialog(null, "Please enter input. ");
dobule dAge ;
dAge= Double.parseDouble(JoptionPane.showInputDialog(null, "Please enter your age. "))//assume user enter his age in the form of String "like twenty instead of 20”. Here, another exception will be generated.
}
Now my question is how can we throw all these exceptions , how can we figure out that what kind of exception will be generated and how can we catch them ????
Thanks ….

mileys81: