Online Java Compiler By
JavaTpoint.com
import java.util.*; public class CollectionsFrequencyExample3 { public static void main(String[] args) { // Let us create an array of integers Integer arr[] = {20, 10, 20, 30, 20, 40, 20}; int freq = Collections.frequency(Arrays.asList(arr), 20); System.out.println("Frequency of 20 is: "+freq); } }
Output