在我的二十一点中,我让玩家击牌或站立,然后测试结束循环,您有以下代码:
int runLoopCount1 = 0;
for (int i = 0; i < players.length; i++) {
if (players[i].wantSplit = false){
if(players[i].getStatus() == true){
runLoopCount1++;
}
}
else if (players[i].wantSplit = true){
if ((players[i].splits[0].busted == true||
players[i].splits[0].standed == true) &&
(players[i].splits[1].busted== true ||
players[i].splits[1].standed == true)){ // null pointer here
runLoopCount1++;
}
}
}
if(runLoopCount1 == players.length){
runLoop = false;
}
现在我得到一个NullPointerException
。我不知道为什么?
最佳答案
你的意思是if(players[i].wantSplit = false)
还是if(players[i].wantSplit == false)
与 if(players[i].wantSplit = true)
或 if(players[i].wantSplit == true)
关于java - 二十一点 split 时爆牌,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/13636113/