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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T00:06:29+00:00 2026-06-16T00:06:29+00:00

if I want id is key and name, phoneNumber, eamil are values. public class

  • 0

if I want “id” is key and “name”, “phoneNumber”, “eamil” are values.

public class Personal {

    private int id;
    private String name;
    private int phoneNumber;
    private String email;

    public Personal(int id){
        this.id = id;
    }

    //getter and setter here
}

after input many person data. I can get data by id.

output ex: map.get(100001); // [Dan, 123456, Dan@gmail.com]
           map.get(100002); // [Kim, 123343, Kim@gmail.com] 
           ...

Question: What’s the best ways to implement this HashMap ?

Thanks a lot!

  • 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-16T00:06:30+00:00Added an answer on June 16, 2026 at 12:06 am

    If the IDs are unique and set in stone, you could use:

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

    To add an object p:

    map.put(p.getId(), p);
    

    Then

    map.get(100001);
    

    would return the corresponding object.

    If the IDs can repeat or can change, things get more complicated. If that’s the case, please explain your exact requirements so that we can help further.

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

Sidebar

Related Questions

I want to parse this Json code : [{id:7,key:integrationContinue:integrationContinue,name:life Portlet,scope:PRJ,qualifier:TRK,date:2012-03-26T10:10:22+0100,lname:life Portlet,lang:java,version:1.0-SNAPSHOT,description:,msr:[{key:ncloc,val:897.0,frmt_val:897},{key:coverage,val:0.6,frmt_val:0,6%}]}] I created two
Suppose the following model : class Product include MongoMapper::Document key :name, String key :product_category_id,
I want to load key/values configuration pairs stored in XML file. To bind a
The scenario: Table1 CatId|Name|Description Table2 ItId|Title|Date|CatId (foreign key) I want to return all rows
I want to have a key insensitive string as key. Is it supported by
If I have data like this: Key Name 1 Dan 2 Tom 3 Jon
I want to get key name from my html element? Sample code : <td
i want to do something like this: e = Employee(key_name = 'john',name='john the first')
Note $thisname and $thisvalue . I want $thisname to be the key/name and value
How would I get the key name for the follow? E.g I want button1

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.