
write a java program to display array list and calculate the average of given array.

class ArrayExample{
public static void main(String[] args)throws Exception{
int sum=0;
int array[]={1,2,5,6,7,3,5,2,3,4};
for(int i=0;i<array.length;i++){
sum+=array[i];
}
System.out.println("Array Elements are: ");
for(int i=0;i<array.length;i++){
System.out.println(array[i]);
}
System.out.println("Sum Of Array Elements is: "+sum);
System.out.println("Average of Array Elements is: "+(double)sum/array.length);
}
}
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.