About Question enthuware.ocpjp.v8.2.1293 :

Moderator: admin

Post Reply
Posts: 125
Joined: Thu Jul 05, 2018 6:44 pm

About Question enthuware.ocpjp.v8.2.1293 :

Post by __JJ__ » Sun Aug 05, 2018 10:56 am

Hi Admin

Code: Select all

HashMap<?, List<String>> box = new HashMap<?, List<String>>();
You cannot have a '?' on the right hand side. I.e. you must provide a type name while instantiating a typed class.
This compiles:

Code: Select all

HashMap<?, List<?>> box = new HashMap<Integer, List<?>>(); 
I bring this up only because otherwise one might be tempted to read your statement as "any appearance of ? on the RHS of = is illegal syntax and will not compile."


Post Reply

Who is online

Users browsing this forum: Bing [Bot] and 6 guests