Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
//License from project: Apache License 

import java.util.*;

public class Main {
    /** Returns true if all elements in the collection are the same */
    public static <T> boolean allEqual(Collection<T> elements) {
        if (elements.isEmpty())
            return false;
        Iterator<T> it = elements.iterator();
        T first = it.next();
        while (it.hasNext()) {
            T el = it.next();
            if (!el.equals(first))
                return false;
        }
        return true;
    }
}