Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.Collection;
import java.util.Iterator;

public class Main {
    /**
     * Compares two collections returning the number of elements they have in common
     * 
     * @param <T>
     * @param one
     * @param two
     * @return
     */
    public static <T> int collectionCompare(Collection<T> one, Collection<T> two) {
        int count = 0;

        Iterator<T> e = one.iterator();
        while (e.hasNext()) {
            if (two.contains(e.next()))
                ++count;
        }

        return count;
    }
}