Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

public class Main {
    /**
     * Instantiates the elements of an array. This is useful because some Java
     * methods set arrays by reference and require the array's elements to be
     * instantiated.
     * 
     * @param elementClass
     *            The class of the array to be instantiated.
     * @param array
     *            The array to be instantiated.
     * @throws IllegalAccessException 
     * @throws InstantiationException 
     */
    public static <T> void instantiateArray(Class<T> elementClass, T[] array)
            throws InstantiationException, IllegalAccessException {
        for (int i = 0; i < array.length; i++) {
            array[i] = elementClass.newInstance();
        }
    }
}