Java List from listOf(T value, int size)

Here you can find the source of listOf(T value, int size)

Description

list Of

License

Open Source License

Declaration

public static <T> List<T> listOf(T value, int size) 

Method Source Code


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

import java.util.List;

public class Main {
    public static <T> List<T> listOf(T value, int size) {
        List<T> list = new ArrayList<T>(size);
        list.add(value);// w ww .ja v  a  2 s .  co  m
        return list;
    }

    public static <T> List<T> listOf(T value) {
        List<T> list = new ArrayList<T>();
        list.add(value);
        return list;
    }

    public static <T> List<T> listOf(T value1, T value2) {
        List<T> list = new ArrayList<T>();
        list.add(value1);
        list.add(value2);
        return list;
    }

    public static <T> List<T> listOf(T value1, T value2, T value3) {
        List<T> list = new ArrayList<T>();
        list.add(value1);
        list.add(value2);
        list.add(value3);
        return list;
    }
}

Related

  1. listOf(double... values)
  2. listOf(E... elements)
  3. listOf(E... elements)
  4. listOf(Iterable it)
  5. listOf(String type)
  6. listOf(T... args)
  7. listOf(T... elements)
  8. listOf(T... elems)
  9. listOf(T... values)