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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T10:11:40+00:00 2026-06-09T10:11:40+00:00

I have a Map like this : Map<String,GridCell> cellsMap I pass this into a

  • 0

I have a Map like this :

Map<String,GridCell> cellsMap

I pass this into a method and the return from that method should contain a Map(say answerMap) which contains all the entries of cellsMap map plus an extra entry that contains a String as the key and a String as the value . Something like :

  Map<String,Object> answerMap  = new ConcurrentHashMap<String,Object>();
    //answer should first contain all the map entries of cellsMap and then add an extra entry like the following
    answer.put(getId(), getSelectionValue()); // getSelectionValue() returns a String that contains coordinates of the selected cells.
     return answerMap; 
  • 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-09T10:11:42+00:00Added an answer on June 9, 2026 at 10:11 am

    Have you considered the Map.putAll() method ?

    e.g.

    answerMap.putAll(cellsMap);
    

    I don’t think this is a good object model, by the way. I think you’re better off creating a new class that contains your original map (maybe a copy) and an additional field for your String/String pair.

    Otherwise you’re throwing objects of different types into the same map, and that’s going to make life complicated when you later extract that info. Each time you extract via a key you’re going to have to check the type of the object returned. Note that ConcurrentHashMaps don’t maintain insertion order.

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

Sidebar

Related Questions

I have a Map of Maps that looks like this: Map<String, Map<String, Object>> data;
I have something like this: Map<String, String> myMap = ...; for(String key : myMap.keySet())
I have a a map that looks like this: public class VerbResult { @JsonProperty("similarVerbs")
I have a Map that uses a Set for the key type, like this:
I have a code like this Map<String, List> searchMap = new HashMap<String, List>(); for(int
I've created a map of vectors that looks like this: map<string, vector<char> > myMap;
Say, I have an XML String like this, <METHOD>foo</METHOD> <PARAM1>abc</PARAM1> <PARAM2>def</PARAM2> ... <PARAM99>ghi</PARAM99> <PARAM100>jkl</PARAM100>
I have a map like this: private Map<String, List<List<String>>> someMap; private List<List<String>> someList1; private
So I have a Map in Scala like this: val m = Map[String, String](
I have a map defined like this std::map<some_key_type, std::string::iterator> mIteratorMap; And a huge string

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.