forked from nbhat1/Selenium-JavaCode
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathTryCatch.java
More file actions
46 lines (37 loc) · 1.02 KB
/
Copy pathTryCatch.java
File metadata and controls
46 lines (37 loc) · 1.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
package main.java.exceptionHandling;
import org.testng.annotations.Test;
/**
* Created by neeraj.bhatnagar on 1/10/2017.
*/
public class TryCatch {
/**
* try block must be followed by either catch or finally block.
* the code that might throw an exception.
*
* catch block is used to handle the exception. It must be used after the try block only.
* we can use multiple catch block with a single try.
*/
public void syntex(){
try {
}catch(Exception e){
}
}
public static void arithmeticException(){
int a = 9/0;
}
/**
* Handling exception
*/
public static void arithmeticExceptionHandling(){
try {
int a = 9 / 0;
}catch (ArithmeticException e){
System.out.println("Code is running fine");
// e.printStackTrace();
}
System.out.println("Code after catching exception");
}
public static void main(String[] args) {
arithmeticExceptionHandling();
}
}