java - 预期出现Java错误<identifier>

标签 java compiler-errors

我目前正在从事Java游戏练习,但遇到了这个难以理解的错误。由于编译器将抛出其中的100个,因此一定是某种语法错误。但是我只是不知道错误在哪里?

import java.util.Random;

public class Poker
{
    private Card[] deck;
    private Card[] hand;
    private int currentCard;
    private int numbers[], triples, couples;
    private String faces[], suits[];

    private boolean flushOnHand, fourOfAKind, isStraight;
    private static final int NUMBER_OF_CARDS = 52;

    private static final Random randomNumbers = new Random();

    Poker()
    {
        faces = { "Ace", "Deuce", "Three", "Four", "Five",
            "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};
        suits = { "Hearts", "Diamonds", "Clubs", "Spades" };

        numbers = new int[ 13 ];

        deck = new Card[ NUMBER_OF_CARDS ];

        triples = 0; // right here's where the compiler starts complaining
        couples = 0;
            ...

虽然我无法发现任何语法错误?

顺便说一句,Card是一个单独的类。

最佳答案

没有理由不能在指示错误的位置分配变量triples

但是,您需要像这样分配String数组:

faces = new String[] { "Ace", "Deuce", "Three", "Four", "Five",
         "Six", "Seven", "Eight", "Nine", "Ten", "Jack", "Queen", "King"};
suits = new String[] { "Hearts", "Diamonds", "Clubs", "Spades" };

关于java - 预期出现Java错误<identifier>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/12342610/

相关文章:

java - 在java中将表从一个数据库复制到另一个数据库(sybase到mysql)

matlab - 在Matlab中使用库(gcc),并在编译mex时出错

c# - CS0176编译器错误。这是什么意思,我该如何解决

java - withSerializationInclusion 函数在最新的 Jackson-databind-2.9.8 中不可用

java - 在 Java 中使用 for 循环将元素从一个列表转移到另一个列表

java - 使用 Jackson JSON 生成器,如何将多个对象写入一个字段?

c++ - 错误 : 'int main(int, char**)' previously defined here in C++

JQgrid : Change entire row's font color if one column is filled

ios - 如何为 iOS 构建 OpenCV 2.4.9?

java - 如何编写一个接受多个客户端Socket的ServerSocket?