• Post Reply Bookmark Topic Watch Topic
  • New Topic

modifying a list collections  RSS feed

 
Mohit Sinha
Ranch Hand
Posts: 125
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Hi All,

I have a method which get a generics list collection object as an input.
The collection contains objects of class TestObj { int id; String name; double amt}. As an input parameter the list is available in the ascending order of id (1,2,3....so on)

Now before i delegate this collection further down we have to modify this collection a bit i.e. based on certain condition we have to rotate some elements to the bottom list.
Since this is an adhoc calculation check I did not go for Comparator /Comparable based ordering.

Here is what I do



This reorder of the list is needed down the line in the app flow. My question here is this appropriate way of doing it or can this be handled in a better fashion


Thanks.
 
Jeff Storey
Ranch Hand
Posts: 230
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Mohit,

I think sorting your list based on a Comparator is a more straightforward way to do it. It makes it a bit clearer as to what you're trying to do.

Jeff
 
fred rosenberger
lowercase baba
Bartender
Posts: 12559
49
Chrome Java Linux
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I put code tags around your source - it preserves the indenting and makes it easier to read. Next time you post, just click the button above where you enter your text labeled 'code' and it will pop them in for you, then paste your source between them.

Thanks
 
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!