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

  • Home
  • SEARCH
  • 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 6014419
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T02:41:22+00:00 2026-05-23T02:41:22+00:00

I have a problem with comparing two arraylist, my first arraylist looks like this:

  • 0

I have a problem with comparing two arraylist,

my first arraylist looks like this:

{TeamID=4, Group=A, TeamName=Germany}
{TeamID=6, Group=A, TeamName=Turkey}

my second list:

{TeamID=4, Chance=99.9%}
{TeamID=6, Chance=38.4%}

and then I want to create one list, which will look like this:

{TeamID=4, Group=A, TeamName=Germany Chance=99.9%}
{TeamID=6, Group=A, TeamName=Turkey Chance=38.4%}

Can You help me ?

First List:

private ArrayList<HashMap<String, String>> TeamList = this.xml.TeamListList;

Second:

private ArrayList<HashMap<String, String>> QChanceList = this.xml.QChanceListList;
  • 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-05-23T02:41:23+00:00Added an answer on May 23, 2026 at 2:41 am

    Here’s one idea. For each team I search for the corresponding entry in the chances list, then I put all entries from both maps into a new one.

    public static List<Map<String, String>> merge(
          List<Map<String, String>> teams, List<Map<String, String>> chances) {
    
      // create the result
      List<Map<String, String>> result = new ArrayList<Map<String, String>>();
    
      // now we assume that for each team there is one chance (valid?)
      for (Map<String, String> team:teams) {
        boolean success = false;
        Map<String, String> combined = new HashMap<String, String>();
        combined.putAll(team);
    
        String id = team.get("TeamID");
    
        // now we have to find the "chance" map
        for (Map<String, String> chance:chances) {
           if (chance.get("TeamID").equals(id)) {
              combined.putAll(chance);
              boolean success = true;
              break;
           }
        }
    
        if (!success) {
          // there was no entry in chances map with this id!! -> handle problem
        }
        result.add(combined);
      }
      return result;
    }
    

    (This example is not very fail-safe, it asserts, that all maps have values for “TeamId”, I just demonstrate that something has to be done in case of illegal input, like an incomplete chances list)

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

Sidebar

Related Questions

Hey I have a problem comparing the value of a CGPoint (struct with two
Possible duplicate : comparing-two-arrays I have two NSArray and I'd like to create a
I have problem compilin this code..can anyone tell whats wrong with the syntax CREATE
I have problem with ActionLink. I'd like to pass to my ActionLink parameter for
I've got the next problem up from this one: Comparing date ranges The solution
My problem is I am comparing two records from different tables and deleting those
I have some simple code that is comparing two float values to illustrate a
I have an android app. in that I am comparing two strings from the
An interesting (and probably simple) problem for you all, I have two arrays, and
I have a big problem with this code and I have no idea how

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.