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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T09:45:42+00:00 2026-06-13T09:45:42+00:00

I have a requirement to have a list, where each element must have 2

  • 0

I have a requirement to have a list, where each element must have 2 values.
I want to know what would be the best way to implement it.
Should I use HashSet, HashMap or anything else ?

The list should look like this –

<Elem1_val1, Elem1_val2>, <Elem2_val1, Elem2_val2>, <Elem3_val1, Elem3_val2>, ....
<Elemn_val1, Elemn_val2>,

The important point here is that val1 and val2 belong to same Element.
What would be a good way to implement this?

UPDATE:

  1. Can anyone comment about implementing – List<Map.Entry<ClassA, ClassB>>
  2. I don’t want to have new class, because I just want to store 2 objects which have
    some co-relation together in one list.

Thanks !

  • 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-13T09:45:43+00:00Added an answer on June 13, 2026 at 9:45 am

    how about creating a class that has two elements and create a List of that class

    class DataHelper{
      String element1;
      String element2;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is a requirement to have not-so-trivial dynamic list, each record of which consists
Say I have a list of integers, where each element is a number from
I am using SQL Server 2005. I have a requirement to list out all
I have requirement to get Facebook friends list with their images. How can I
I have a requirement to store the list of services for multiple computers. I
Helo. I have the following requirement: I have a list (ListView or Spinner depends
I have a SharePoint list with Content Approval enabled. The business requirement is that
I got requirements- 1. Have random values in a List/Array and I need to
I have requirement where some times I would like to load children as well
I have a table named config . Each config row has a list of

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.