-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexception3.java
More file actions
33 lines (32 loc) · 840 Bytes
/
exception3.java
File metadata and controls
33 lines (32 loc) · 840 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
class exception3
{
public static void main(String[] args)
{
try
{
int arr[]=new int[3];//3
System.out.println("this code will run");
try
{
System.out.println("the value at arr[3] is "+arr[3]);//accesing 4th position exception occured at this line
}
catch(ArrayIndexOutOfBoundsException a)
{
//a.getMessage();this is working
System.out.println("plz access the right index og array !");
//a.printStackTrace();
}
System.out.println("this code will work");
System.out.println("this code will work");
System.out.println("this code will work");
System.out.println("this code will work");
System.out.println("this code will work");
System.out.println("this code will work");
}
catch(Exception abc)
{System.out.println("u r accessing wrong index position");
System.out.println(abc.getMessage());
}
System.out.println("this code will work !");
}
}