Logo

Programming-Idioms

History of Idiom 134 > diff from v18 to v19

Edit summary for version 19 by programming-idioms.org:
[Java] +DocURL

Version 18

2016-12-06, 22:21:35

Version 19

2016-12-07, 20:44:54

Idiom #134 Create a new list

Declare and initialize a new list items, containing 3 elements a, b, c.

Idiom #134 Create a new list

Declare and initialize a new list items, containing 3 elements a, b, c.

Extra Keywords
array vector slice tuple
Extra Keywords
array vector slice tuple
Imports
import java.util.List;
import java.util.ArrayList;
Imports
import java.util.List;
import java.util.ArrayList;
Code
List<T> items = new ArrayList<>();
items.add(a);
items.add(b);
items.add(c);
Code
List<T> items = new ArrayList<>();
items.add(a);
items.add(b);
items.add(c);
Comments bubble
T is the type of a, b, c.
Comments bubble
T is the type of a, b, c.
Doc URL
http://docs.oracle.com/javase/8/docs/api/java/util/ArrayList.html#ArrayList--
Demo URL
http://ideone.com/WrGIl9
Demo URL
http://ideone.com/WrGIl9