Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

import java.util.Arrays;
import java.util.Collections;
import java.util.List;

public class Main {
    public static void main(String[] args) {
        List<Integer> values = Arrays.asList(5, 0, 0, 2);
        int occurrences = Collections.frequency(values, 0);
        System.out.println("occurrences of zero is " + occurrences);

        occurrences = Collections.frequency(values, 5);
        System.out.println("occurrences of 5 is " + occurrences);
    }
}