data-flair.training/blogs exception
try {
//Code where exception can occur
}
catch(ExceptionTypeA e1) {
//code that executes if Exception of type A occurs
}
catch(ExceptionTypeB e2) {
//code that executes if Exception of type B occurs.
}
data-flair.training/blogs exception
try {
//Code where exception can occur
}
catch(ExceptionTypeA e1) {
//code that executes if Exception of type A occurs
}
catch(ExceptionTypeB e2) {
//code that executes if Exception of type B occurs.
}
data-flair.training/blogs exception
package com.dataflair.javaexceptions;
import java.io. * ;
public class CheckUnCheck {
public static void main(String[] args) throws IOException {
try {
System.out.println(25 / 0);
System.out.println("This statement will never get executed because the control has shifted to the catch block. ");
}
catch(Exception e) {
System.out.println("You are trying to divide by zero! That is not right!");
}
finally {
System.out.println("This code is in the finally block. It does not depend on whether an exception occurs or not. ");
}
}
}
Copyright © 2021 Codeinu
Forgot your account's password or having trouble logging into your Account? Don't worry, we'll help you to get back your account. Enter your email address and we'll send you a recovery link to reset your password. If you are experiencing problems resetting your password contact us