java 运行

[复制链接]
查看11 | 回复2 | 2009-11-13 23:22:03 | 显示全部楼层 |阅读模式
for(int i = len-1; i>=1; i--) { for(int j=0; j= 1; i--) { for (int j = 0; j0) {
Date temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
} }}return a; }}class Date { int year, mouth, day; Date(int y, int m, int d) {year = y;mouth = m;day = d; } public int compare(Date date) {return year > date.year ? 1 : yeardate.mouth ? 1 : mouthdate.day ? 1 : day < date.day ? -1 : 0; } public String toString() {return year + "年" + mouth + "月" + day + "日"; }}要改写一下toString方法。
回复

使用道具 举报

千问 | 2009-11-13 23:22:03 | 显示全部楼层
编译要生成类文件,编译成功后,运行主要的那个类文件就可以了啊!
回复

使用道具 举报

千问 | 2009-11-13 23:22:03 | 显示全部楼层
public String toString() {return year + "," + mouth + "," + day; }没有重写toString()方法。System.out.println(days);打印不出对象里存放的值。
回复

使用道具 举报

您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

主题

0

回帖

4882万

积分

论坛元老

Rank: 8Rank: 8

积分
48824836
热门排行