This week's book giveaway is in the Kotlin forum.
We're giving away four copies of Kotlin in Action and have Dmitry Jemerov & Svetlana Isakova on-line!
See this thread for details.
Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

Objects and Collections  RSS feed

 
sri rallapalli
Ranch Hand
Posts: 88
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
in K&B book,
page no:18, of Objects and Collections chapter, figure says that LinkedHashMap is not an instance of HashMap.
But in the following example, it is showing that LinkedHashMap is an instance of HashMap.

import java.util.*;
class GFC111 {
public static void main (String[] args) {
Object m = new LinkedHashMap();
System.out.print((m instanceof Collection)+",");
System.out.print((m instanceof Map)+",");
System.out.print(m instanceof HashMap);
}}
Please Calrify my Doubt. I want to know whether the figure in K&B book is wrong or correct.
thanks,
Sri.
 
Henry Wong
author
Sheriff
Posts: 23283
125
C++ Chrome Eclipse IDE Firefox Browser Java jQuery Linux VI Editor Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
According to the Javadoc, the LinkedHashMap class does indeed inherit from the HashMap class.

Henry
 
Bert Bates
author
Sheriff
Posts: 8945
17
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Dang!

How did I miss that one

Just finishing up the errata list - so far 5 confirmed errata, and about 5 good suggestions...
 
ak pillai
author
Ranch Hand
Posts: 288
 
Don't get me started about those stupid light bulbs.
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!