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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T12:49:01+00:00 2026-06-11T12:49:01+00:00

I have a list of objects that contain row data for a table. There

  • 0

I have a list of objects that contain row data for a table. There are multiple columns in that table but I don’t think that’s an issue. The logic I need to apply would require only two columns. These two columns are known as Chemical Name and Batch Number . Now the interesting part here is that a chemical can occur many times for a particular batch number. For example,

CHEMICAL | BATCH | OTHER COLUMNS

A—————-100———ABC

A—————-100———GHF

A—————-100———GHL

Now what I need is the batch number and its associated rows. I realized that the best way to do this would be HashMap where K is Batch number and V is a List. Now I am not sure how to assign a Key to a List containing row objects.

I wish but I cannot do this at the database level so that is out of question.

  • 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-11T12:49:02+00:00Added an answer on June 11, 2026 at 12:49 pm

    Or you could just use guava library. There is Multimap class(technically interface) to fit your need: One key mapping to multiple values.

    You might first get all your Row objects in a list, then use the Multimaps.index method to create a Multimap instance. Multimaps is a util class which provide a lot of methods to create a Multimap instance.

    Your code maybe looks like:

    List<Row> rows = ... // all the row objects.
    Multimap<String, Row> rowsMap = Multimaps.index(rows, new Function<Row, String>() {
        @Override
        public String apply(Row row) {
            return row.getRowKey(); // assume that getRowKey() return the key of one row.
        }
    });
    

    See more details from guava api.

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

Sidebar

Related Questions

I have a listview that is loaded with a list of objects that contain
I have a class Player that contains a list of Accessory objects. There are
I have a Ticket class that contains a List of User objects: class Ticket
I have a list of objects that have two int properties. The list is
I have a List of objects that I would like to convert to a
I have a List of String objects that are pipe delimited. something like this:
I have a list/collection of objects that may or may not have the same
I have a list of pointers that reference time objects that need a turn
I have a list of IDs for objects that I need to grab, then
Im using a BaseAdapter and passing to it a List of objects that have

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.