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
Can a class have multiple superclasses?
What is the indent key?
what is static import in java? Explain
How to make object serializable in java?
What is an error in java?
Explain hashset and its features?
enlist some features of jdk.
Can a main method be overloaded?
What is a native method in java programming?
Which is bigger float or double java?
What is main method?
What is sortedset in java?
What is the best definition for data?
Why java uses the concept of the string literal?
What is passing value java?