• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

Objects and Collections

 
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
Marshal
Pie
Posts: 21427
84
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: 8900
5
  • 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
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic