File APIs for Java Developers
Manipulate DOC, XLS, PPT, PDF and many others from your application.
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

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.
Henry Wong

Joined: Sep 28, 2004
Posts: 20526

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


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

Joined: Oct 14, 2002
Posts: 8898

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
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
I agree. Here's the link:
subject: Objects and Collections
jQuery in Action, 3rd edition