Here you can find the source of toArrayList(String[] stringArray)
ArrayList
, containing the elements of a supplied array of String
objects.
Parameter | Description |
---|---|
stringArray | The array of <code>String</code> objects that have to be converted. |
ArrayList
with the elements of the String
array.
public static List<String> toArrayList(String[] stringArray)
//package com.java2s; /*// w ww .ja va 2 s . c o m * Copyright 2001-2013 Geert Bevin (gbevin[remove] at uwyn dot com) * Licensed under the Apache License, Version 2.0 (the "License") */ import java.util.*; public class Main { /** * Creates a new <code>ArrayList</code>, containing the elements of a * supplied array of <code>String</code> objects. * * @param stringArray The array of <code>String</code> objects that have * to be converted. * @return The new <code>ArrayList</code> with the elements of the * <code>String</code> array. * @since 1.0 */ public static List<String> toArrayList(String[] stringArray) { List<String> strings = new ArrayList<>(); if (null == stringArray) { return strings; } Collections.addAll(strings, stringArray); return strings; } }