Java List from Array asList(String... strings)

Here you can find the source of asList(String... strings)

Description

Returns from a variable number of String parameters a List<String>

License

Apache License

Parameter

Parameter Description
strings the variable number of Strings to be converted to a list.

Return

the list of strings.

Declaration

public static List<String> asList(String... strings) 

Method Source Code


//package com.java2s;
//   Licensed under the Apache License, Version 2.0 (the "License");

import java.util.ArrayList;
import java.util.List;

public class Main {
    /**//w  ww  .  ja  va 2s. c  om
     * Returns from a variable number of String parameters a <code>List&lt;String&gt;</code>
     * 
     * @param strings the variable number of Strings to be converted to a list.
     * @return the list of strings.
     */
    public static List<String> asList(String... strings) {
        List<String> listOfStrings = new ArrayList<>(strings.length);
        for (int i = 0; i < strings.length; i++) {
            listOfStrings.add(strings[i]);
        }

        return listOfStrings;
    }
}

Related

  1. asList(String string)
  2. asList(String strList, String regex)
  3. asList(String val)
  4. asList(String valuesSeparatedBy, String delimiter)
  5. asList(String... args)
  6. asList(T element)
  7. asList(T firstItem, T... otherItems)
  8. asList(T... a)
  9. asList(T... a)