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 6865677
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T03:05:01+00:00 2026-05-27T03:05:01+00:00

Possible Duplicate: Isn't it easier to work with foo when it is represented by

  • 0

Possible Duplicate:
Isn't it easier to work with foo when it is represented by the class ArrayList rather than the interface List?
Why are most of the examples using ArrayList

Why do we mostly do, like this :

Map<Integer, String> map = new HashMap<Integer, String>();

instead of :

HashMap<Integer, String> map = new HashMap<Integer, String>();

& similar while instantiating ArrayList(s).

  • 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-05-27T03:05:02+00:00Added an answer on May 27, 2026 at 3:05 am

    Less typing, Map is the Interface (same with List) for that class so it’s easier to pass a Map around than a HashMap since the functionality is the same the only difference is the implementation. This is usually done (in some cases) when lets say for some reason you decide that HashMap isn’t what you want and you want to use TreeMap instead but in all of your code there’s HashMap parameters and changing those can be a pain. If you pass Map instead you don’t have to change anything and your code can be a lot more flexible.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Possible duplicate: why-is-java-lang-throwable-a-class Hi! I doesn't understand why Throwable isn't abstract class. I see
Possible Duplicate: How does the Google Did you mean? Algorithm work? Suppose you have
Possible Duplicate: Why isn’t sizeof for a struct equal to the sum of sizeof
Possible Duplicate: Why isn’t sizeof for a struct equal to the sum of sizeof
Possible Duplicate: Why isn't more Java software compiled natively? I know that Java is
Possible Duplicate: Why does it appear that my random number generator isn't random in
Possible Duplicate: Why must I put a semicolon at the end of class declaration
Possible Duplicate: What does the tilde (~) mean in C#? class ResourceWrapper { int
Possible Duplicate: Why do /**/ comments work in stylesheets but // comments don't? In
Possible Duplicate: Why isn't String.Empty a constant? I wanted to use string.Empty in the

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.