Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Collection;

public class Main {
    static int total = 0;

    public static int Cardinality(Object obj, Collection coll) {
        if (coll == null) {
            throw new NullPointerException();
        }
        if (obj == null) {
            throw new NullPointerException();
        }
        for (Object o : coll) {
            if (o.equals(obj)) {
                total++;
            }
        }
        return total;
    }
}