这是什么错误 the literal octal 08 (digit 8) of type int out of range

li_589 2008-07-06 09:00:50

package com.lwj;

public class TestDateArraySort {

public static void main(String[] args) {
DateDay[] date = new DateDay[5];
date[0] = new DateDay(2008, 07, 06);
date[1] = new DateDay(2008, 07, 07);
date[2] = new DateDay(2008, 07, 08);//错误 the literal octal 08 (digit 8) of type int out of range
date[3] = new DateDay(2008, 07, 09);//错误 the literal octal 08 (digit 8) of type int out of range
date[4] = new DateDay(2008, 07, 10);
bubbleSort(date);
for (int i = 0; i < date.length; i++)
System.out.println(date[i]);
}

public static DateDay[] bubbleSort(DateDay[] 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) {
DateDay temp = a[j];
a[j] = a[j + 1];
a[j + 1] = temp;
}
}
}
return a;
}

}

class DateDay {
private int year;

private int month;

private int day;

DateDay(int year, int month, int day) {
this.day = day;
this.month = month;
this.year = year;
}

public int compare(DateDay date) {
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;

}

public String toString() {
return "year" + year + " month " + month + " day " + day;
}
}
这是什么错误?
...全文
356 6 打赏 收藏 转发到动态 举报
AI 作业
写回复
用AI写文章
6 条回复
切换为时间正序
请发表友善的回复…
发表回复
秋月渡长河 2010-12-15
  • 打赏
  • 举报
回复
[Quote=引用 5 楼 zhj92lxs 的回复:]
哦说错了,你这样写它是按8进制来计算的,所以08、09不认了
[/Quote]
果真如此,多谢啦!
zhj92lxs 2008-07-06
  • 打赏
  • 举报
回复
哦说错了,你这样写它是按8进制来计算的,所以08、09不认了
li_589 2008-07-06
  • 打赏
  • 举报
回复
06,07它认识为什么08,09为认识
zhj92lxs 2008-07-06
  • 打赏
  • 举报
回复
你的07、06、08、09它不认的,把0去掉
li_589 2008-07-06
  • 打赏
  • 举报
回复
date[3] = new DateDay(2008, 07, 09);//错误 the literal octal 08 (digit 9) of type int out of range

62,635

社区成员

发帖
与我相关
我的任务
社区描述
Java 2 Standard Edition
社区管理员
  • Java SE
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧