-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtry_catch.java
More file actions
42 lines (38 loc) · 1.3 KB
/
try_catch.java
File metadata and controls
42 lines (38 loc) · 1.3 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
import java.util.Scanner;
public class try_catch {
void func1()
{
try
{
int ar[]= new int[5];
Scanner sc = new Scanner(System.in);
System.out.println("Enter Element in array ");
for(int i=0; i<5;i++){
ar[i]= sc.nextInt();
}
System.out.println("/n /n ......................Array Elements............\n\n");
for(int i=5; i>0;i++){
System.out.println(ar[i]/i);
}
// String var1=sc.next();
// System.out.println("String value : ");
// System.out.print(var1);
// System.out.println("\n\n.....................\n\n");
// int x = Integer.parseInt(var1);
// System.out.println("Numerical value :");
// System.out.println(x+ "...................try block");
sc.close();
}
catch(ArrayIndexOutOfBoundsException e)
{
System.out.println("Array problem occur");
}
catch(ArithmeticException e1){
System.out.println("Mathmatical problem occur");
}
}
public static void main(String[] args) {
try_catch obj = new try_catch();
obj.func1();
}
}