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 java.lang.reflect.Array;

import java.util.List;

public class Main {
    /**
     * Get a double array from a list given
     * @param list List with Objects that can be translated to double
     * @param klass Class type of array
     * @return Object array of elements
     */
    public static Object getObjectArray(List list, Class klass) {
        Object array = Array.newInstance(klass, list.size());
        for (int i = 0; i < list.size(); i++) {
            Array.set(array, i, list.get(i));
        }
        return array;
    }
}