Leave a Reply 2

Your email address will not be published. Required fields are marked *


xxx

xxx

public class Painting {

public static void main(String[] args){
int arr[] = new int[4];
arr[0] = 1;
arr[1] = 2;
arr[2] = 4;
arr[3] = 5;
int sum = 0;
try{
for(int pos=0; pos<=4; pos++){

sum = sum + arr[pos];
}
}
catch (Exception e ){
System.out.println("invalid");
}

System.out.println(sum);
}
}

b