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 is assembly condition codes?
When should you use arraylist and when should you use linkedlist?
What is static synchronization?
Can we override private methods?
Is empty in java?
What is bool mean?
How many types of design patterns are there?
What is an interoperable application in java ?
What method is used to specify a container's layout in java programming?
What is data type modifier?
What is the final method?
How do you define a singleton class?
What are inner classes or non static nested classes in java?
What is the memory leak in java?
What is the set interface in java programming?