I've bit of a problem here - The scenario is as below:
I've a list that consists of objects from a particular class. each of the objects contains instance variables like concentration, volume etc (ones i'am concerned here is concentration and volume alone)
Once the objects are populated from the Application based on user inputs, I need to compare the concentration values from this list of objects and classify apart the objects that have same concentrations and ones that have different.
If the concentrations are same, i need to add the volumes and display them, else if the concentrations differ , then i 've to display the volumes seperately.
How do i do this?. Would appreciate some help here.
Sunil Baby wrote:How do i do this?. Would appreciate some help here.
My suggestion would be to create a Comparator that orders your objects by their concentration. That way you can then use Collections.sort() to sort your List by concentration. After that, the selection/grouping process is up to you; but it should be pretty straightforward.
Isn't it funny how there's always time and money enough to do it WRONG?
Articles by Winston can be found here