Java 错误:无法取消对int的引用

Java 错误:无法取消对int的引用,java,compiler-errors,int,dereference,primitive-types,Java,Compiler Errors,Int,Dereference,Primitive Types,在编译时,我似乎遇到了一个“Error:int不能被取消引用”错误。我已经查找了发生这种情况的原因,尽管如此,我不确定该如何解决它 public class NetID_BaseballPitcher { Scanner in = new Scanner(System.in); private final int maxgames = 20; private int[] gamesPitched = new int[maxgames]; private int c

在编译时,我似乎遇到了一个“Error:int不能被取消引用”错误。我已经查找了发生这种情况的原因,尽管如此,我不确定该如何解决它

public class NetID_BaseballPitcher
{
    Scanner in = new Scanner(System.in);
    private final int maxgames = 20;
    private int[] gamesPitched = new int[maxgames];
    private int count, totalRuns;
    private float totalInnings;

    public int inputGameData()
    {
        for(int i = 0; i < count; i++)
        {
            gamesPitched[i] = new NetID_BaseballGame();
            gamesPitched[i].inputGame();
        }
    }  
}

我假设我遗漏了一些非常明显的东西,我只是在原地打转。任何帮助都将不胜感激

您已声明
gamespictched
int
值的数组,但这不是您需要的。从需求来看,您应该这样声明:

private NetID_BaseballGame[] gamesPitched = new NetID_BaseballGame[MAX_GAMES];
您还需要在某个地方初始化
count
变量

NetID_BaseballPitcher.java:45: error: incompatible types
            gamesPitched[i] = new NetID_BaseballGame();
                          ^
  required: int
  found:    NetID_BaseballGame
NetID_BaseballPitcher.java:46: error: int cannot be dereferenced
        gamesPitched[i].inputGame();
private NetID_BaseballGame[] gamesPitched = new NetID_BaseballGame[MAX_GAMES];