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 javax.annotation.Nonnull;
import javax.annotation.Nullable;

public class Main {
    @Nullable
    public static <E> E firstElementOfType(@Nonnull final Class<E> type,
            @Nonnull final Iterable<? super E> elements) {

        for (final Object element : elements)
            if (type.isInstance(element))
                return type.cast(element);

        return null;
    }
}