java - 二十一点 split 时爆牌

标签 java

在我的二十一点中,我让玩家击牌或站立,然后测试结束循环,您有以下代码:

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/

相关文章:

Java应用程序设计建议: storing image

java - 从 C++ 在 Java 中重新组装两个字节,没有得到预期的结果

Java 方法返回带有动态对象的 HashMap<key, Object>

java - jOOQ - 加入嵌套子查询

java - 最终变量作为方法参数

java - 有人可以分解这条线以便我理解吗?

java - Android 以编程方式存储的图像在 PC 上格式无效

java - 死存储到 List 对象 - 如何解决?

java - nginx - Spring Boot 应用程序的多个反向代理(启用 Spring Security)

Java Graphics2D 缩放字体以填充背景