Java 口袋妖怪游戏。返回数组时遇到问题

Java 口袋妖怪游戏。返回数组时遇到问题,java,methods,return,Java,Methods,Return,我很失落,很沮丧。为什么我不能返回opponentstats以及其中的值!感谢您的帮助。该方法声明为返回int 尝试返回的变量类型为int[] 因此,要么将返回类型更改为int数组,要么返回单个int值(不是数组!) 非常感谢你直截了当的回答!!信息量大,容易理解!我很高兴我们能很快解决这个问题:-) public static int wildPokemon(int opponentstats[] , int rattataStats[] , int geodudeStats[] , in

我很失落,很沮丧。为什么我不能返回opponentstats以及其中的值!感谢您的帮助。

该方法声明为返回int

尝试返回的变量类型为int[]


因此,要么将返回类型更改为int数组,要么返回单个int值(不是数组!)

非常感谢你直截了当的回答!!信息量大,容易理解!我很高兴我们能很快解决这个问题:-)
public static int wildPokemon(int opponentstats[] , int  rattataStats[] , int  geodudeStats[] , int  pidgeyStats[])
{
rattataStats = new int[]{27,42,35};
geodudeStats = new int[]{35,45,80};
pidgeyStats = new int[]{39,33,33};

System.out.println(".");
Pause(1000);
System.out.println(".");
Pause(1000);
System.out.println(".");
Pause(1000);   

Random wildPokemon = new Random();
int opponent = (wildPokemon.nextInt(3));
while(true)
{
if(opponent == 0)
{
 System.out.println("You have come across a wild Rattata!!!");
 rattataStats[0] = opponentstats[0];
 rattataStats[1] = opponentstats[1];
 rattataStats[2] = opponentstats[2];
 return opponentstats;

}
else if(opponent == 1)
{
  System.out.println("You have come across a wild Geodude!!!");
 geodudeStats[0] = opponentstats[0];
 geodudeStats[1] = opponentstats[1];
 geodudeStats[2] = opponentstats[2];
 return opponentstats;

}
else if(opponent ==-2)
{
  System.out.println("You have come across a wild Pidgey!!!");
 pidgeyStats[0] = opponentstats[0];
 pidgeyStats[1] = opponentstats[1];
 pidgeyStats[2] = opponentstats[2];
 return opponentstats;
}
}
}