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 meant by Garbage collection?
What is the Concept of Encapsulation in OOPS
how to run ecllipse with jettyserver for windows environment using batch file
What is methods and methodology?
What does the exclamation mark mean in java?
What are the 3 types of control structures?
What are the advantages of assembly language?
What are the different types of java?
How to perform quicksort in java?
What is a lock or purpose of locks in java?
What is nullpointerexception in java?
In case of inheritance what is the execution order of constructor and destructor?
What is mnemonic code?
How many bits is a float?
Which command from the jdk compiles a java program?