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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T03:33:48+00:00 2026-06-03T03:33:48+00:00

I have researched this question for ages and cannot get it right! I have

  • 0

I have researched this question for ages and cannot get it right!

I have a populated hashmap and an identically formatted hashmap (Map<Integer, ArrayList<String>>) that I have been working on (it has key value/s equal to other keys in the populated hashmap such as 0,1,2 etc). When I use the .put command to update the populated hashmap the few/one I have been working on replaces everything in the populated hashmap – is this normal? Where am I going wrong? I was expecting it to simply replace the key in question + values….

Excuse the not supplying code but it would mean posting quite an amount to demonstrate, just wondering if anyone could help explain where this might be going wrong. I could throw something together to show if needed…

Much obliged!

  • 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-03T03:33:50+00:00Added an answer on June 3, 2026 at 3:33 am

    This is how a code example might look like:

    import java.util.*;
    
    public class NumFormEx
    {
        public static ArrayList <String> listIt (String... params) 
        {
            ArrayList <String> as = new ArrayList <String> ();
            for (String s: params)
                as.add (s);
            return as;
        }
    
        public static void main (String args[])
        {
            Map <Integer, ArrayList<String>> mils = new HashMap<Integer, ArrayList<String>> ();
            mils.put (1, listIt ("foo", "bar")); 
            mils.put (2, listIt ("zacka", "zacka")); 
            System.out.println ("mils:\t" + mils);
            mils.put (1, listIt ("foobar"));        
            System.out.println ("mils:\t" + mils);
        }
    }
    

    Testing:

    java NumFormEx
    mils:   {1=[foo, bar], 2=[zacka, zacka]}
    mils:   {1=[foobar], 2=[zacka, zacka]}
    

    I would say: as expected.

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

Sidebar

Related Questions

I apologize in advance for this somewhat ignorant question, but I have researched this
I should start by saying I have researched this question. I can't find any
I have researched this for a few hours and I am kind of frustrated.
I have researched enough on this topic sans any luck :-( My requirement is
I'm learning c++, and I'm a bit of a newbie. I've researched this question
I know this question has been asked many times and I've researched it myself
Greetings, Apologies in advance that I have not researched this toughly enough to answer
I have done some research on this question and most answers are a few
I have been struggling with this NHibernate issue for hours. I extensively researched on
This question has two aspects, both related to indices. I have a dataset with

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.