Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.*;

public class Main {
    public static Object findSingleObject(Collection c) {
        if (c == null || c.isEmpty())
            return null;
        if (c.size() > 1)
            throw new IllegalStateException("found more than one object when single object requested");
        return c.iterator().next();
    }
}