How to get the most recent of a set of date variables in Java

advertisements

I have about 8 date variables (java.util.Date) with different variable names. What's the most efficient/best way of choosing the most recent (max) of these dates?


Ideally, store them in a collection - this might make sense in terms of your program design anyway. If you have e.g. a List object, you can do:

Collections.max(dates);