Compares two Dates for ordering.
Specified by:compareTo in interface Comparable<Date>Parameters:anotherDate - the Date to be compared.
Returns:the value 0 if the argument Date is equal to this Date; a value less than 0 if this Date is before the Date argument; and a value greater than 0 if this Date is after the Date argument.Throws:NullPointerException - if anotherDate is null.Since:1.2
主要看的是最后一段,我给你翻译一下:
返回值:如果返回值是0 的话说明这两个日期相等,如果返回值小于零的话就说明这个日期在anotherDate之前,也就是比anotherDate大,如果大于0说明这个日期在anotherDate之后,也就说这个日期比anotherDate小。明白了吗?作者: Lo_Twilight 时间: 2015-1-28 21:45
俩循环啊~作者: 流星划过的黎明 时间: 2015-2-1 23:30
compareTo
public int compareTo(Date anotherDate)比较两个日期的顺序。
指定者:
接口 Comparable<Date> 中的 compareTo
参数:
anotherDate - 要比较的 Date。
返回:
如果参数 Date 等于此 Date,则返回值 0;如果此 Date 在 Date 参数之前,则返回小于 0 的值;如果此 Date 在 Date 参数之后,则返回大于 0 的值。