aspose file tools*
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Objects and Collections Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Bookmark "Objects and Collections" Watch "Objects and Collections" New topic
Author

Objects and Collections

sri rallapalli
Ranch Hand

Joined: Mar 15, 2005
Posts: 88
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

Joined: Sep 28, 2004
Posts: 18896
    
  40

According to the Javadoc, the LinkedHashMap class does indeed inherit from the HashMap class.

Henry


Books: Java Threads, 3rd Edition, Jini in a Nutshell, and Java Gems (contributor)
Bert Bates
author
Sheriff

Joined: Oct 14, 2002
Posts: 8829
    
    5
Dang!

How did I miss that one

Just finishing up the errata list - so far 5 confirmed errata, and about 5 good suggestions...


Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
ak pillai
author
Ranch Hand

Joined: Feb 11, 2006
Posts: 288
public class LinkedHashMap extends HashMap implements Map


java j2ee job interview questions with answers | Learn the core concepts and the key areas
 
Consider Paul's rocket mass heater.
 
subject: Objects and Collections