番石榴构建器保存多次键入type参数。比较:
List<Foo<Bar, Baz>> list = Lists.newArrayList();
List<Foo<Bar, Baz>> list = new ArrayList<Foo<Bar, Baz>>();
但是在Java 7中,它已经过时了,因为您拥有菱形运算符:
List<Foo<Bar, Baz>> list = new ArrayList<>();
Lists.newArrayList与新ArrayList
番石榴构建器保存多次键入type参数。比较:
List<Foo<Bar, Baz>> list = Lists.newArrayList();
List<Foo<Bar, Baz>> list = new ArrayList<Foo<Bar, Baz>>();
但是在Java 7中,它已经过时了,因为您拥有菱形运算符:
List<Foo<Bar, Baz>> list = new ArrayList<>();