Я, кажется, получаю сообщение об ошибке «Ошибка: int не может быть разыменован» при компиляции. Я искал причины, почему это происходит, и, несмотря на это, я не уверен, как я могу это исправить.Ошибка: 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();
}
}
}
А вот Baseballgame.java
public class NetID_BaseballGame
{
private static int runs;
private static int gameNum;
private static float innings;
public static void inputGame()
{
do
{
System.out.print("Game # ");
gameNum = in.nextInt();
} while(gameNum < 0);
do
{
System.out.print("Number Innings");
innings = in.nextInt();
} while((innings < 0) && (innings > 10));
do
{
System.out.print("Number Runs");
runs = in.nextInt();
} while(runs < 0);
}
}
При составлении BaseballPitcher.java, я получаю это:
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();
Я предполагаю, что я что-то совершенно очевидно не хватает, и я просто вращаюсь там, где я нахожусь. Любая помощь будет принята с благодарностью!