Hi, i need to find the max value of ArrayList<ArrayList>. I don't know whether it is possible or not? Can anyone please give me some suggestion.

Any help from you will highly be appreciated....

Check Collections.max Sample usage:

ArrayList<Integer> al = new ArrayList<Integer>();
//add values
Object o = Collections.max(al);
System.out.print("Max: " + o );

Hope this helps

Thanks for your reply. I tried this but i found an error saying...

"Bound mismatch: The generic method min(Collection<? extends T>) of type Collections is not applicable for the arguments (ArrayList<ArrayList>). The inferred
type ArrayList is not a valid substitute for the bounded parameter <T extends Object & Comparable<? super T>>"

Actually i have 3 arraylist in 1 arraylist. Now i need to find the max of the the 3 arraylist separately.

search for Comparator

Oh I mistakenly disregarded <ArrayList> part. If that is the case, do you want to get the maximum in terms of the size of the ArrayList?

No actually i want the values contained in the 3 arraylist in terms of string type, i need to use them to display in 3 JLabels. Please give me some suggestion...


Loop the ArrayList. Then each element is also an ArrayList. So take each element of the first ArrayList and loop that to in an inner loop:

ArrayList<ArrayList> [B]list[/B]
loop [B]list[/B] {
  take each array_list inside [B]list[/B]
  loop that array_list {
    // do whatever

But I don't think that it is good practice to have an ArrayList of array lists

Thank you i got the idea. Now i can do.... Thanks for your help...