我有这个代码,并试图编译它 . 但它给了我
错误:找不到符号anotherEntry = keyBoard.nextInt(); symbol:变量keyBoard location:class DemoVariables3
有什么线索的原因?
码:
import java.util.Scanner;
public class DemoVariables3
{
public static void main(String[] args)
{
int entry;
int anotherEntry;
System.out.print("Enter another integer ");
anotherEntry = keyBoard.nextInt();
System.out.print("The other entry is ");
System.out.println(anotherEntry);
System.out.println(entry + "plus" +
anotherEntry + "is" + (entry + anotherEntry));
}
}
1 回答
在尝试使用变量
keyBoard
之前,需要创建名为keyBoard
的变量并将其分配给新的Scanner
对象: