-
Notifications
You must be signed in to change notification settings - Fork 52
Expand file tree
/
Copy pathtxt.java
More file actions
38 lines (32 loc) · 853 Bytes
/
txt.java
File metadata and controls
38 lines (32 loc) · 853 Bytes
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
public class Main5 {
public void divide(int a, int b){
int c;
if (b==0){
throw new ArithmeticException("Value is not correct");
}
else{
c=a/b;
System.out.println(c);
}
}
public void ArrayExcp(){
int ar[] = { 1, 2, 3, 4, 5 };
for (int i = 0; i <= ar.length; i++)
System.out.println(ar[i]);
throw new ArrayIndexOutOfBoundsException("ArrayIndexOutOfBoundsException");
}
public void nullPointer(String a){
if (a=="null"){
throw new NullPointerException("this is Null pointer Exception");
}
else {
System.out.println(a);
}
}
public static void main(String[] args) {
Main5 m1 = new Main5();
m1.divide(2,0);
m1.ArrayExcp();
m1.nullPointer(null);
}
}