Java tutorial
//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; } } }