所以,这是我的代码:
import java.util.Scanner;
public class FootballsGivenAway
{
public static void main(String [] args)
{
int FinalScore;
**int TouchdownNumber=BallsGivenAway;**
int BallsGivenAway=TouchdownNumber;
Scanner inputDevice= new Scanner(System.in);
System.out.print("What was the final score of the Carolina Panthers? ");
FinalScore=inputDevice.nextInt();
System.out.print("Out of the points the Panthers scored, how many of them were touchdowns? ");
TouchdownNumber=inputDevice.nextInt();
System.out.println("The Carolina Panthers gave away this number of footballs today: " + BallsGivenAway);
}
}
编译器继续以粗体显示返回“无法找到符号”错误。我该怎么做才能解决这个问题?
答案 0 :(得分:1)
在声明之前,不能在Java中使用局部变量。如果您查看代码,可以看到在下一行声明TouchdownNumber
之前,您尝试将BallsGivenAway
设置为BallsGivenAway
。
此外:
BallsGivenAway
设置回TouchDownNumber
?你定义了两个变量,它们的值应该是......另一个变量?