1import java.util.Arrays;
2import java.util.Scanner;
3public class SumOfElementsOfAnArray {
4 public static void main(String args[]){
5 System.out.println("Enter the required size of the array :: ");
6 Scanner s = new Scanner(System.in);
7 int size = s.nextInt();
8 int myArray[] = new int [size];
9 int sum = 0;
10 System.out.println("Enter the elements of the array one by one ");
11
12 for(int i=0; i<size; i++){
13 myArray[i] = s.nextInt();
14 sum = sum + myArray[i];
15 }
16 System.out.println("Elements of the array are: "+Arrays.toString(myArray));
17 System.out.println("Sum of the elements of the array ::"+sum);
18 }
19}