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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T17:59:43+00:00 2026-06-14T17:59:43+00:00

I need to store information in Key Value manner. But the built-in Map interface

  • 0

I need to store information in Key Value manner. But the built-in Map interface cannot fit for my requirement. Java Map requires both Key and Values to be reference, while I need to use primitive value as key.

Is there any data structure something like Map ? Thanks for your help!

Requirement Details:

My server written in Java runs as a daemon listening a tcp port. When a user first connect in, details about the user need to be stored in KV manner, and the second time the user connect in, his details should be able to read from the KV data structure.

I cannot use the user object as key, for it will be destructed when disconnect, and reconstructed in the second connection. The two objects are not the same reference. Integer key doesn’t fit for my requirement either for the same reason.

In other words, I need to use value as key, not reference.

Keys could be considered are: UUID(long), id(int) and so on. They are all primitive type.

  • 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-14T17:59:44+00:00Added an answer on June 14, 2026 at 5:59 pm

    I fail to see why you can’t simply wrap your primitive type in it’s corresponding non-primitive class and use that as your key in a regular java map.

    Map<Integer, Object> map = new HashMap<Integer, Object>();
    Integer key = Integer.valueOf(5);
    Object test = new Object();
    map.put(key, test);
    Object test2 = map.get(Integer.valueOf(5));
    
    test.equals(test2); // will be true
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I need to use STL C++ map to store key value pairs. I need
Did you ever have the following situation: you need to store information, but a
I need to use XML file to store each key/value pair used by my
I need a dictionary-like data structure that stores information as follows: key [value 1]
When I need to store time/date information, how is it best to be stored
I need a field to store some information after one asp button click for
I need to store pairs of float,int in which the int value stores the
I need a regex for parsing key-value-pairs from a properties-file to write them into
Looking to store public/private key information securely on an iOS device. I know I
I have a Java class with private static maps used to store information during

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.