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 we use this () and super () in a method?
What do you mean by inner class in java?
How to make a class or a bean serializable?
What are the main features of java?
What is floor math?
What is meant by method?
What is a native method in java programming?
How do you declare an array that will hold more than 64KB of data?
How do constructors use this() and super()?
What a static class can contains?
What is the unit of plancks constant?
How do you replace all in word?
What is polymorphism and what are the types of it?
Is a case study a method or methodology?
What is instanceof keyword?