- , . ( - exceptions), : 0, , (, ). () , , , .
. , - , , "" - .
Java, , . try (), catch, finally.
, , . throw . .
:
try{
0;
}
catch (1 1){
1;
}
catch (2 2){
2;
}
catch (N N){
N;
}
finally{
;
}
, try-catch-finally ; , . - .
, 0 try , finally. try, , catch (). catch , , . e ( exception). , , . catch .
, , catch finally. , " ". finally . finally , tryfinally, try catch break, continue, return System.exit, , . finally, .
:
void myETest(String s,double y){
double x, z;
try{
x=Double.parseDouble(s);
z=Math.sqrt(x/y);
} catch(ArithmeticException e){
System.out.println(" ");
} catch(NumberFormatException e){
System.out.println(" !");
}
};