aspose file tools
The moose likes Java in General and the fly likes modifying a list collections Big Moose Saloon
  Search | Java FAQ | Recent Topics
Register / Login
JavaRanch » Java Forums » Java » Java in General
Reply Bookmark "modifying a list collections" Watch "modifying a list collections" New topic
Author

modifying a list collections

Mohit Sinha
Ranch Hand

Joined: Nov 29, 2004
Posts: 125
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

Joined: Apr 07, 2007
Posts: 230
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


Jeff Storey
Software Developer
[url]http://jeffastorey.blogspot.com[/url]
fred rosenberger
lowercase baba
Bartender

Joined: Oct 02, 2003
Posts: 9955
    
    6

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


Never ascribe to malice that which can be adequately explained by stupidity.
 
I agree. Here's the link: http://zeroturnaround.com/jrebel - it saves me about five hours per week
 
subject: modifying a list collections
 
Similar Threads
equals hashcode
html:checkbox or html:multibox
How to convert java object in a request scope to javascript object???
populate list property in bean
Collections and Generics Help