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
What will happen if static modifier is removed from the signature of the main method?
How many types of exception can occur in a java program?
What is the longest unicode character?
What is an association?
Can we make the abstract methods static in java?
What is not thread safe?
What is the declaration statement?
What is thread safe singleton?
What loop means?
What is the use of hashmap in java?
Can we create our own wrapper class in java?
how to one war file class to another war file class?
How do you detect memory leaks?
Is the empty set a singleton?
How many types of voids are there?