• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Bear Bibeault
  • Liutauras Vilda
Sheriffs:
  • Jeanne Boyarsky
  • Junilu Lacar
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Jj Roberts
  • Tim Holloway
  • Piet Souris
Bartenders:
  • Himai Minh
  • Carey Brown
  • salvin francis

merging two lists inside a list

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
hi all,
i want to merge two lists inside a list
[] --> ArrayList
c1,c2,c3,c4,c5 --> different objects of the same class (eg. some customer class)

merging criteria::

[[c1,c2],[c3,c4],[c1,c5]] to [[c1,c2,c5],[c3,c4]]
also
[[c1,c2],[c2,c3],[c3,c4]] to [[c1,c2,c3,c4]]

Thing is, its like lists inside a list.

Hope you can help me implementing this.

Thanks

 
Marshal
Posts: 67478
173
Mac Mac OS X IntelliJ IDE jQuery Java
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Please check your private messages for important administrative matters.
 
Ranch Hand
Posts: 492
Firefox Browser VI Editor Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
There is a method in the ArrayList API that allows you to add a Collection to the ArrayList, you can sort after that.

Hunter.
 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Assuming that you already have the list of lists structure, what you need to do is to figure out:
1. How to traverse this structure
2. How to combine the lists that should be merged (See the hint from the previous post)
3. How to collect the merged lists into the final list (If you managed to build up the list of lists structure this is done )

Artur
 
With a little knowledge, a cast iron skillet is non-stick and lasts a lifetime.
reply
    Bookmark Topic Watch Topic
  • New Topic