Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.Collection;

public class Main {
    @SuppressWarnings("unchecked")
    public static <E> E[] asArray(final Collection<? extends E> collection) {
        return collection.toArray((E[]) new Object[collection.size()]);
    }

    @SuppressWarnings("unchecked")
    public static <E> E[] asArray(final Object... array) {
        final E[] elements = (E[]) new Object[array.length];
        for (int i = 0; i < array.length; i++) {
            elements[i] = (E) array[i];
        }
        return elements;
    }
}