About Question enthuware.ocpjp.v7.2.1380 :

Help and support on OCA OCP Java Programmer Certification Questions
1Z0-808, 1Z0-809, 1Z0-815, 1Z0-816, 1Z0-817

Moderator: admin

Post Reply
Alexey Berezkin
Posts: 20
Joined: Fri Jun 19, 2015 9:17 am
Contact:

About Question enthuware.ocpjp.v7.2.1380 :

Post by Alexey Berezkin »

Why the first option incorrect? Please try the following:

Code: Select all

Map<Map<?, ?>, String> m = new HashMap<Map<?, ?>, String>();
m.put(m, "value");
System.out.println(m);
The output is:

Code: Select all

{(this Map)=value}
You see, this is considered even a special case and properly handled in AbstractMap.toString().

admin
Site Admin
Posts: 10388
Joined: Fri Sep 10, 2010 9:26 pm
Contact:

Re: About Question enthuware.ocpjp.v7.2.1380 :

Post by admin »

Well, as per JavaDoc API description of Map
The behavior of a map is not specified if the value of an object is changed in a manner that affects equals comparisons while the object is a key in the map. A special case of this prohibition is that it is not permissible for a map to contain itself as a key.

Post Reply

Who is online

Users browsing this forum: No registered users and 8 guests