About Question enthuware.ocpjp.v7.2.1263 :
Posted: Thu Apr 17, 2014 1:33 am
Hi!
1. It is necessary to replace "list3" in option 3 with "list". Otherwise the message "cannot find symbol" will appear in line
The first special case of combining wild card ? and new keyword is illustrated here: http://docs.oracle.com/javase/tutorial/ ... print.html (right after words "However, you can still use wildcard arrays"):
1. It is necessary to replace "list3" in option 3 with "list". Otherwise the message "cannot find symbol" will appear in line
2. It seems to me that the explanationSystem.out.println(list.get(0));
is not very clear.Remember that wild card (i.e. ?) is never used while creation of the generic type object.
The first special case of combining wild card ? and new keyword is illustrated here: http://docs.oracle.com/javase/tutorial/ ... print.html (right after words "However, you can still use wildcard arrays"):
The second example (which also compiles fine) I've found in the description of JAX-RS Web Services:List<?>[] lsa = new List<?>[10];
public Set<Class<?>> getClasses() {
Set<Class<?>> set = new HashSet<Class<?>>();
set.add(MyClass.class);
return set;
}