Ng Sharma wrote:Best Answer.
https://stackoverflow.com/questions/4343202/difference-between-super-t-and-extends-t-in-java
Stephan van Hulst wrote:On a tangent: In general you don't need to worry about the A parameter. You only need to care about it if you implement your own Collector.
Tim Holloway wrote:Try this with 1:59 instead of 2:00. You might find it interesting. Indeed, try 1:59:59
Campbell Ritchie wrote:But Comparator is a functional interface.
Campbell Ritchie wrote:But Comparator is a functional interface.
Campbell Ritchie wrote:Have you seen the documentation for Collections#sort()?
Stephan van Hulst wrote:You need to tell us what part of the explanation is not clear to you, and explain to us why you think it is 0.
Stephan van Hulst wrote:What part don't you understand?
Think of it as follows -
The time difference between two dates is simply the amount of time you need to go from date 1 to date 2.
So if you want to go from 1AM to 2AM, how many hours do you need? On a regular day, you need 1 hour. That is, if you add 1 hour to 1AM, you will get 2AM. However, as given in the problem statement, at the time of DST change, 2 AM becomes 1AM. That means, even after adding 1 hour to 1AM, you are not at 2AM. You have to add another hour to get to 2 AM. In total, therefore, you have to add 2 hours to 1AM to get to 2AM.
The answer can therefore be short listed to 2 or -2. Now, as per the JavaDoc description of the between method, it returns negative value if the end is before the start. In the given code, our end date is 1AM, while the start date is 2AM. This means, the answer is -2.
Stephan van Hulst wrote:Which answer do you think, and why?