Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8125903
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 6, 20262026-06-06T06:58:23+00:00 2026-06-06T06:58:23+00:00

Possible Duplicate: Java.util.HashMap — why HashMap extends AbstractMap and implement Map? In java to

  • 0

Possible Duplicate:
Java.util.HashMap — why HashMap extends AbstractMap and implement Map?

In java to implement HashMap<K,V> we need to implement Map<K,V>.

However when I debugged more in java classes it seems that…. java defines HashMap class as following.

public class HashMap<K,V>
extends AbstractMap<K,V>
implements Map<K,V>, Cloneable, Serializable

At the same time i saw public abstract class AbstractMap<K,V> implements Map<K,V> it also implements the interface Map<K,V>.

If abstract class implements the interface then, what is the reason behind implementing Map<K,V> at HashMap class level?

As per my understanding HashMap class have all the methods inherited from AbstractMap which can be overridden by HashMap as per the requirement.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-06T06:58:24+00:00Added an answer on June 6, 2026 at 6:58 am

    I believe the reasoning behind this is an abstract class in Java need not declare/implement all the methods in the interface.
    Thus

    public interface MyInterface{
      void a();
      void b();
      void c();
    }
    

    the following abstract implementation of the interface is valid.

    public abstract class AbstractClass implements MyInterface {
      public void a() {}
      public void c() {}
      public void d() {}
    }
    

    Thus I believe in order to be explicit about HashMap implementing the methods not implemented by the abstract class it is shown to implement the interface Map whereas it is completely optional to do so because any implementation of the abstract class needs to implement all the methods either in the abstract class or the derived base class..
    Thus in the above example a valid implementation to the abstract class is

    public class MyClass extends Abstract{
          public void a() {}
          public void c() {}
          public void b() {}  //if you dont implement this, compile error
          public void d() {}
        }
    

    which you can rewrite as follows too:

    public class MyClass extends Abstract implements MyInterface {
          public void a() {}
          public void c() {}
          public void b() {}
          public void d() {}
        }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible Duplicate: Get generic type of java.util.List I have a Map and I want
Possible Duplicate: Memory overhead of Java HashMap compared to ArrayList I try to search
Possible Duplicate: Java Generics To be more specific, whats the role of the <String>
Possible Duplicate: How to reference another property in java.util.Properties? look at my file.properties: key1=
Possible Duplicate: How to get date of last Friday from specified date? Using java.util.Calendar
Possible Duplicate: Java: “implements Runnable” vs. “extends Thread” When should you use: class MyThread
Possible Duplicate: Java: Start Mail-Client with Attachment? I need to create a java code
Possible Duplicate: How to reference another property in java.util.Properties? I want to refer to
Possible Duplicate: Java how to: Generic Array creation import java.util.EmptyStackException; import java.util.Vector; public class
Possible Duplicate: Java - Regex problem I have list of URLs of types: http://www.example.com/pk/etc

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.