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 are the advantages of java inner classes?
Does unicode support all languages?
what is collatration?
How to optimize the javac output?
What is append function?
What is static variable with example?
What are default methods ?
What is lambda in java?
What is a vector in java?
What is the program development process?
What is hashset in java?
Does java support multiple inheritances?
Give us a program to check for parenthesis matching using stack.
Are arrays static in java?
What is the difference between jfc & wfc?