Write a java program to create a singly linked list and display the element code example
Example: Write a java program to create a singly linked list and display the element
import java.util.Scanner;public class Main{public static void main(String[] args) {int n, sum = 0;float average;Scanner s = new Scanner(System.in);System.out.print("Enter number of elements you want in array");n = s.nextInt();int a[] = new int[n];System.out.println("Enter all the elements");for(int i = 0; i < n ; i++){a[i] = s.nextInt();sum = sum + a[i];}System.out.println("Sum"+sum);average = (int)sum / n;System.out.println("Average"+average);}}