This week's book giveaway is in the Agile and other Processes forum.
We're giving away four copies of The Mikado Method and have Ola Ellnestam and Daniel Brolund on-line!
See this thread for details.
The moose likes Programmer Certification (SCJP/OCPJP) and the fly likes Objects and Collections Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login


Win a copy of The Mikado Method this week in the Agile and other Processes forum!
JavaRanch » Java Forums » Certification » Programmer Certification (SCJP/OCPJP)
Reply 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: 16695
    
  19

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: 8712
Dang!

How did I miss that one

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


Eliminate fossil fuel subsidies. (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
 
I agree. Here's the link: http://ej-technologies/jprofiler - if it wasn't for jprofiler, we would need to run our stuff on 16 servers instead of 3.
 
subject: Objects and Collections
 
Similar Threads
Dan's Question
Map Question
LinkedHashMap and HashMap
Maps
Doubt in K&B Book Collection Hirerchy Figure