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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T00:26:11+00:00 2026-06-13T00:26:11+00:00

I am storing some data in a hash map. Now I want to modify

  • 0

I am storing some data in a hash map. Now I want to modify the values associated with a key based on a user input and store them these way permanently.

To make myself more clear, I have a hashmap like this:

public static HashMap<String,Integer> mymap= new HashMap<String,Integer>();
mymap.put("Hi",2);
mymap.put("Hello",3);

I will take feedback from user in some user and if he wants then I will, say, store 4 against Hello. I want these changes to be saved for future references.

I have heard about Reflection API in Java, but am not sure whether that will serve the purpose.

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

    Reflection API allows one to manipulate/access data that is not accessable otherwise – or some data on the class that is unknown at compile time.

    In here, it is really not needed. All you need is to put() the element into the map, it will “remove” the old value from the key you just inserted (if it is already there) and associate it (the key) with the newly added value.

    So, basically – all you need to do is myMap.put(key,newValue), and the implementation of the Map (assuming it is a correct one, of course) will take care of the rest.


    If you want to store the data between runs of the program – you will have to save it (the map) on disk. In order to do so, you can use serialization, or if you can use Properties in some cases.

    Make sure that you load the map from disk once the program starts, or you will not see the values you stored.

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

Sidebar

Related Questions

We have to lookup some data based on three input data fields. The lookup
In our application we use std::map to store (key, value) data and use serialization
My application is storing some data in SQL Table called Transactions. Users are able
Imagine a web-application storing some data-resource with some id which stores three attachment (e.g.
I am looking for some examples on storing some data into Google cloud storage
I am fetching data from some tables & storing it in a variable like
Seem to be having some issues storing the current date in a core data
I have a string in c# containing some data i need to extract based
I saved some data in the database using mysql_real_escape_string() so the single quotes are
I'm trying to figure out how to extract some data from a string according

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.