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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T13:18:36+00:00 2026-06-17T13:18:36+00:00

Below is data from 2 linkedHashMaps: valueMap: { y=9.0, c=2.0, m=3.0, x=2.0} formulaMap: {

  • 0

Below is data from 2 linkedHashMaps:

valueMap:   { y=9.0, c=2.0, m=3.0, x=2.0}
formulaMap: { y=null, ==null, m=null, *=null, x=null, +=null, c=null, -=null, (=null, )=null, /=null}

What I want to do is input the the values from the first map into the corresponding positions in the second map. Both maps take String,Double as parameters.

Here is my attempt so far:

for(Map.Entry<String,Double> entryNumber: valueMap.entrySet()){
   double doubleOfValueMap = entryNumber.getValue();
   for(String StringFromValueMap: strArray){
      for(Map.Entry<String,Double> entryFormula: formulaMap.entrySet()){          
         String StringFromFormulaMap = entryFormula.toString();
         if(StringFromFormulaMap.contains(StringFromValueMap)){
           entryFormula.setValue(doubleOfValueMap);
         }
      }
   }
}

The problem with doing this is that it will set all of the values i.e. y,m,x,c to the value of the last double. Iterating through the values won’t work either as the values are normally in a different order those in the formulaMap. Ideally what I need is to say is if the string in formulaMap is the same as the string in valueMap, set the value in formulaMap to the same value as in valueMap.

Let me know if you have any ideas as to what I can do?

  • 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-17T13:18:38+00:00Added an answer on June 17, 2026 at 1:18 pm

    This is quite simple:

    formulaMap.putAll(valueMap);
    

    If your value map contains key which are not contained in formulaMap, and you don’t want to alter the original, do:

    final Map<String, Double> map = new LinkedHashMap<String, Double>(valueMap);
    map.keySet().retainAll(formulaMap.keySet());
    formulaMap.putAll(map);
    

    Edit due to comment It appears the problem was not at all what I thought, so here goes:

    // The result map
    for (final String key: formulaMap.keySet()) {
        map.put(formulaMap.get(key), valueMap.get(key));
    
    // Either return the new map, or do:
    valueMap.clear();
    valueMap.putAll(map);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have data below from streaming: 'ID|20120206|080500|0000001|0|1|record1|END' 'ID|20120206|080500|0000002|0|1|record2|END' 'ID|20120206|080500|0000003|0|1|record3|END' and i want to process
First of all, i'm using the function below to read data from a pdf
Hi there i want to get data from the below combo box in cakephp
I want to get filter column string from below Data. URL PreFix OutPut ConcatStrings
The code below simply gets data from database and populate the data into TextBoxes
I am attempting to insert data from a dictionary into a database. I want
I have a piece of matlab code below which reads data from a table.
I am trying to parse data from the XML below (I shortened the data
I am trying to read data from a file stream as shown below: fileStream.Read(byteArray,
I got the below Exception when i wnat to get the data from another

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.