Page 1 of 1

About Question enthuware.ocpjp.v8.2.1263 :

Posted: Thu Apr 14, 2016 11:01 am
by raphaelalex
In explanation the following code actually works:

Code: Select all

List<String> list = new ArrayList<>();
List<? extends String> list2 = new ArrayList<>();
list.add("A");
list.addAll(new ArrayList<>());
list.addAll(list2);
System.out.println(list.size());
please, review explanation section with a valid example.
Thanks. ;)

Re: About Question enthuware.ocpjp.v8.2.1263 :

Posted: Thu Apr 14, 2016 9:22 pm
by admin
Unfortunately, it doesn't compile in Java 7 but does compile in Java 8.
Even Oracle's official tutorial says it should not compile.

-Paul.