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.HashSet;
import java.util.Set;

public class Main {
    @SuppressWarnings({ "rawtypes", "unchecked" })
    public static boolean containsOnly(Collection collection, Object object) {
        if (collection == null)
            return false;
        Set duplicatesRemoved = new HashSet(collection);
        return duplicatesRemoved.size() == 1 && duplicatesRemoved.contains(object);
    }
}