Answer Posted / nitesh
Right now two ways come to my mind.
First:
Create a TreeSet, add all the dates to it. They get
sorted by default since java.util.Date implements
comparable. Here is an example -->
Set<Date> sortedDates = new TreeSet<Date>();
sortedDates.add(new Date());
Calendar cal = Calendar.getInstance();
cal.set(2009, 2, 12);
sortedDates.add(cal.getTime());
Second:
We can use the compare method inside Date class
directly and write our own sorting implementation.
Is This Answer Correct ? | 11 Yes | 5 No |
Post New Answer View All Answers
How many types of memory areas are allocated by jvm?
What is core java called?
What is flush () in java?
Does .length start 0 java?
What is super constructor?
What is the multi-catch block in java?
What is the difference between the prefix and postfix forms of the ++ operator?
Explain scope or life time of local variables in java?
What is ‘has a’’ relationship in java?
What is the use of isempty in java?
How do you clear an arraylist in java?
What is the super void?
What is jpa specification?
For class CFoo { }; what default methods will the compiler generate for you>?
Difference between arraylist and vector.