Creates a mutable ArrayList containing the given elements. @param the generic type of the ArrayList to create. @param elements the elements to store in the ArrayList. @return the created ArrayList, of null if the given array of elements is {@code
(T... elements)
| 33 | * @return the created {@code ArrayList}, of {@code null} if the given array of elements is {@code null}. |
| 34 | */ |
| 35 | @SafeVarargs |
| 36 | public static <T> ArrayList<T> newArrayList(T... elements) { |
| 37 | if (elements == null) { |
| 38 | return null; |
| 39 | } |
| 40 | ArrayList<T> list = newArrayList(); |
| 41 | java.util.Collections.addAll(list, elements); |
| 42 | return list; |
| 43 | } |
| 44 | |
| 45 | /** |
| 46 | * Creates a <em>mutable</em> {@link ArrayList} containing the given elements. |