It depends on what you mean by initialization. To just initialize a variable timewith the value of a link to a new one ArrayList, you do
ArrayList<String> time = new ArrayList<String>();
(replace Stringwith the type of objects you want to keep in the list.)
If you want to put the material on the list, you can do
ArrayList<String> time = new ArrayList<String>();
time.add("hello");
time.add("there");
time.add("world");
You can also do
ArrayList<String> time = new ArrayList<String>(
Arrays.asList("hello", "there", "world"));
or using an instance initializer
ArrayList<String> time = new ArrayList<String>() {{
add("hello");
add("there");
add("world");
}};
source
share