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 {
    public static Object getFirstObject(Collection<?> collection) {
        Iterator<?> iterator = collection.iterator();

        if (iterator.hasNext()) {
            return iterator.next();
        } else {
            return null;
        }
    }
}