java新手提问

chen_yalei 2004-02-11 01:17:04
源代码:
class ImprovedFibonacci{
static final int MAX_INDEX = 9;

public static void main(String[] args){
Two[] that = new Two[10];
that[0].Num = 1;
that[0].mark = false;
that[1].Num = 1;
String marks;

System.out.println("1:"+that[0].Num);
for(int i = 2;i<=MAX_INDEX;i++){
if( that[i-1].Num % 2 == 0 )
{
that[i-1].mark = true;
marks="*";
}
else
{
that[i-1].mark = false;
marks="";
}
System.out.println(i+":"+that[i-1].Num+marks);
that[i].Num = that[i-2].Num + that[i-1].Num;
that[i-1].Num = that[i].Num - that[i-2].Num;
}
}
}

class Two{
public int Num;
public boolean mark;
}

错误信息:
Exception in thread "main" java.lang.NullPointerException
at ImprovedFibonacci.main(ImprovedFibonacci.java:6)

请问错在哪里阿?
...全文
64 1 打赏 收藏 转发到动态 举报
写回复
用AI写文章
1 条回复
切换为时间正序
请发表友善的回复…
发表回复

62,614

社区成员

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

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