I need a java program to find how many times do the duplicate elements occur in a java arraylist (collections class) This is my current code and I want to continue this to count the number of times when the duplicate elements occur in the array list import java.util.*; public class NumberCount{ public static void main(String args[]) { System.out.println("Enter how many elements have to be entered"); Scanner x= new Scanner(System.in); int n=x.nextInt(); ArrayList<Integer> a= new ArrayList<Integer>(); for(int i=0;i<n;i++) { System.out.println("Enter your element"); Scanner y= new Scanner(System.in); int k=y.nextInt(); a.add(k); } System.out.println("Elements: "+a); } } } | 0 |