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)

请问错在哪里阿?
...全文
26 点赞 收藏 1
写回复
1 条回复
切换为时间正序
当前发帖距今超过3年,不再开放新的回复
发表回复

还没有回复,快来抢沙发~

相关推荐
发帖
Java SE
创建于2007-09-28

6.1w+

社区成员

Java 2 Standard Edition
申请成为版主
帖子事件
创建了帖子
2004-02-11 01:17
社区公告
暂无公告