Java List from listOfOne()

Here you can find the source of listOfOne()

Description

Create an array list of the given type of size 1.

License

Open Source License

Declaration

public static <T> ArrayList<T> listOfOne() 

Method Source Code

//package com.java2s;
/*******************************************************************************
 *  Copyright (c) 2012 Google, Inc.//w w  w  .  ja v a2  s  .c  o m
 *  All rights reserved. This program and the accompanying materials
 *  are made available under the terms of the Eclipse Public License v1.0
 *  which accompanies this distribution, and is available at
 *  http://www.eclipse.org/legal/epl-v10.html
 *  
 *  Contributors:
 *  Google, Inc. - initial API and implementation
 *******************************************************************************/

import java.util.ArrayList;

public class Main {
    /**
     * Create an array list of the given type of size 1.
     */
    public static <T> ArrayList<T> listOfOne() {
        return new ArrayList<T>(1);
    }
}

Related

  1. listOf(T... values)
  2. listOfArrays(T[]... values)
  3. listOfExceptionsAsString(List exs)
  4. listOfIntegers2ArrayOfInts(List xs)
  5. listOfItems(List items, String separator, String finalConjunction)
  6. listOfOne(T x)
  7. listOfStrings(int size, String prefix)
  8. listOfStrToString(List src, String del)