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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T04:17:11+00:00 2026-06-03T04:17:11+00:00

I have an arrayList of arrayLists. Each inner arraylist contains some objects with the

  • 0

I have an arrayList of arrayLists. Each inner arraylist contains some objects with the format (name.version) .

{  {a.1,b.2,c.3} , {a.2,d.1,e.1} , {b.3,f.1,z.1}....} 

For example a.1 implies name = a and version is 1.

So i want to eliminate duplicates in this arraylist of lists. For me , two objects are duplicate when they have the same name

So essentially my output should be

{ { a.1,b.2,c.3},{d.1,e.1} ,{f.1 ,z.1} }

Note that i want the output in the exact same form (That is , i dont want a single list with no duplicates)

Can someone provide me with an optimal solution for this?

I can loop through each inner list and place the contents in the hashset. But two issues there, i cant get back the answer in
form of list of lists.Another issue is that when i need to override equals for that object , but i am not sure if that would
break other code. These objects are meaningfully equal if their names are same (only in this case. I am not sure that would
cover the entire spectrum)

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-03T04:17:13+00:00Added an answer on June 3, 2026 at 4:17 am
    List<List<Pair>> inputs; // in whatever format you have them
    List<List<Pair>> uniqued = new ArrayList<>(); // output to here
    Set<String> seen = new HashSet<String>();
    for (List<Pair> list : inputs) {
      List<Pair> output = new ArrayList<>();
      for (Pair p : list)
        if (seen.add(p.getName()))
          output.add(p);
      uniqued.add(output);
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ArrayList of objects where each object contains a string 'word' and
I have an ArrayList with custom objects. Each custom object contains a variety of
I have an ArrayList that I want to use to hold RaceCar objects that
I have an ArrayList containing Objects that have a date value. Now I want
I have a class that contains two arraylists which I'm trying to store objects
For example, I have an ArrayList: ArrayList<Animal> zoo = new ArrayList<Animal>(); // some code
I have a arraylist and it contains a 100 employee object and each object
i have an arraylist of objects, each containing a year/month/day/hour property. what i'm ultimately
I have an arraylist of objects, each containing a unique date in the following
I have a Arraylist of rabbits. Each rabbit has a String name and a

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.