Main.java Source code

Java tutorial

Introduction

Here is the source code for Main.java

Source

//package com.java2s;
import java.util.*;

public class Main {
    public static <T> List<T> listOf(T a) {
        List<T> list = newEmptyList();
        list.add(a);
        return list;
    }

    public static <T> List<T> newEmptyList() {
        return new ArrayList<>();
    }

    public static <T> List<T> add(List<T> list, T a) {
        List<T> newList = newEmptyList();
        newList.addAll(list);
        newList.add(a);
        return newList;
    }
}