Lists.newArrayList vs new ArrayList

The guava builder saves typing the type arguments multiple times. Compare:

List<Foo<Bar, Baz>> list = Lists.newArrayList();
List<Foo<Bar, Baz>> list = new ArrayList<Foo<Bar, Baz>>();

In Java 7 it’s a bit obsolete though, because you have the diamond operator:

List<Foo<Bar, Baz>> list = new ArrayList<>();

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)