-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExcepArray.java
More file actions
47 lines (38 loc) · 788 Bytes
/
ExcepArray.java
File metadata and controls
47 lines (38 loc) · 788 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
39
40
41
42
43
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package javapep;
class ExcepArray extends Exception
{
ExcepArray(String s)
{
super(s);
}
}
class t{
public static void main(String args[]) throws ExcepArray
{
int arr1[]={1,5,7,8,9,10};
int arr2[]={1,5,7,8,9};
try
{
int sum1=0;
if(arr1.length==arr2.length)
{
for(int i=0;i<arr1.length;i++)
{
sum1=sum1+arr1[i]+arr2[i];
}
System.out.println("sumof two arrays ="+sum1);
}
else{
throw new ExcepArray("Not same size");
}
}catch(Exception e)
{
System.out.println("Exception occured: "+e.getMessage());
}
}
}