Java List Value Add add(List aList, T anObj)

Here you can find the source of add(List aList, T anObj)

Description

Adds an object to the given list and returns list (creates list if missing).

License

Open Source License

Declaration

public static <T> List<T> add(List<T> aList, T anObj) 

Method Source Code


//package com.java2s;

import java.util.*;

public class Main {
    /**/*from  ww  w  .ja  va2s .co  m*/
     * Adds an object to the given list and returns list (creates list if missing).
     */
    public static <T> List<T> add(List<T> aList, T anObj) {
        // If list is null, create list
        if (aList == null)
            aList = new Vector();

        // Add object
        aList.add(anObj);

        // Return list
        return aList;
    }
}

Related

  1. add(List list, Object[] array)
  2. add(List data, Object... values)
  3. add(List> target, E value)
  4. add(List a, List b)
  5. add(List list, String value)
  6. add(List aList, T anObject)
  7. add(List current, T toAdd)
  8. add(List list, int i, T v)
  9. add(List list, T element)

  10. HOME | Copyright © www.java2s.com 2016