• Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

parent class for Java.util.Map

 
Deepika Saxena
Ranch Hand
Posts: 59
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi,
could any body let me know the parent class of java.util.Map interface? as per my knowledge it is java.lang.Object. Please correct me if i am wrong.
--Deepika
 
Rob Spoor
Sheriff
Pie
Posts: 20512
54
Chrome Eclipse IDE Java Windows
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
An iterface does not have a parent class. It can have multiple "parent" interfaces, if it extends multiple interfaces.

As for a class that implements Map, you can't tell its parent class without knowing the class. Some classes may have Object as the parent class, implementing Map completely themselves. Others may extend AbstractMap, inheriting some methods from it. Others may even extend an existing Map implementation. An example is java.util.Properties, which extends java.util.Hashtable which in turn extends java.util.Dictionary which in turn extends Object. In this hierarchy, only Hashtable and Properties are Maps.
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34210
341
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Rob said everything I can think on the topic. Since it sounds like you are new to Java, it's probably also helpful to show you how to find this information yourself.

If you go to the JavaDoc for the Map interface, you can see the declaration is:


By contrast, the one for Hashmap is:


As you can see HashMap extends AbstractMap. And it's easy to find out once you know how!
 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic