04-24-2011, 06:55 PM
You can throw multiple exceptions as follows
public void method() throws IOException, NullPointerException //so on you can add as many as you want or require and this will be handled in caller //function
{
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. ");
double 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.
}
IOException can catch all type of exceptions.
public void method() throws IOException, NullPointerException //so on you can add as many as you want or require and this will be handled in caller //function
{
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. ");
double 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.
}
IOException can catch all type of exceptions.
0300-9520262
Get solution in 24 hour |cpmputer & internet
mileys81:[SIZE="4"][SIZE="3"]....[/SIZE][/SIZE]
