为什么用UltraEdit自动改字母大小写? public class TestDateSort { public static void main(String[] args) { Date[] days = new Date[5]; days[0] = new Date(2006, 5, 4); days[1] = new Date(2006, 7, 4); days[2] = new Date(2008, 5, 4); days[3] = new Date(2004, 5, 9); days[4] = new Date(2004, 5, 4);
bubbleSort(days);
for(int i = 0; i < days.length; i++) { System.out.println(days[i]); } }
public static Date[] bubbleSort(Date[] a) { int len = a.length; for(int i = len - 1; i >= 1; i--) { for(int j = 0; j <=i - 1; j++) { if(a[j].compare(a[j+1]) > 0) { Date temp = a[j]; a[j] = a[j + 1]; a[j + 1] = temp; } } } return a; }
class Date { int year, month, day;
Date(int y, int m, int d) { year = y; month = m; day = d; }
public int compare(Date date) { 就是这一行的最后那个“date”,我用UltraEdit一保存就自动变成“Dtae”,为什么啊? return year > Date.year ? 1 : year < Date.year ? -1 : month > Date.month ? 1 : month < Date.month ? -1 : day > Date.day ? 1 : day < Date.day ? -1 : 0; } } }