Logo

Programming-Idioms

History of Idiom 134 > diff from v16 to v17

Edit summary for version 17 by programming-idioms.org:
[Java] Comment about T

Version 16

2016-12-04, 22:36:19

Version 17

2016-12-04, 22:37:02

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.
Demo URL
http://ideone.com/WrGIl9
Demo URL
http://ideone.com/WrGIl9