Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;

import java.util.ArrayList;
import java.util.Arrays;

import java.util.List;

public class Main {
    /** Returns a new List containing the given objects. */
    public static <T> List<T> makeList(T... items) {
        return new ArrayList<T>(Arrays.asList(items));
    }

    public static List<Integer> asList(int[] a) {
        List<Integer> result = new ArrayList<Integer>(a.length);
        for (int i = 0; i < a.length; i++) {
            result.add(Integer.valueOf(a[i]));
        }
        return result;
    }

    public static List<Double> asList(double[] a) {
        List<Double> result = new ArrayList<Double>(a.length);
        for (int i = 0; i < a.length; i++) {
            result.add(new Double(a[i]));
        }
        return result;
    }
}