[求助]编译正常,但是运行出错?
public class JosephNode{
public int ID;
public int TurnID; //˳Ðò
public int next; //Ï൱ÓÚC++µÄÖ¸Õë
};
public class Joseph
{
public static void main(String[] arg)
{
JosephNode node[] = new JosephNode[12];
for(int i=0;i<node.length;i++)
{
node[i].ID = node[i].TurnID = i+1;
node[i].next = (i+1)%node.length;
}
int left = 12,count = 0,i=0;
while(left==1)
{
node[i].TurnID = (count++)%5;
if(node[i].TurnID==0)
{
node[(left+i-1)%12].next++;
left--;
}
i = node[i].next;
}
System.out.println("the "+i+" will out");
}
};
//出错提示
Exception in thread "main" java.lang.NullPointerException
at Joseph.main(Joseph.java:8)
Press any key to continue...