1

当我尝试输入以下代码时,使用 javac 命令时出现语法错误:

import java.util.Scanner;

public class DemoVariables3
{


public static void main(String[] args)
{
int entry;
Scanner keyBoard = new Scanner(System.in);
System.out.print("Enter an Integer");
entry = keyBoard.nextInt();
System.out.print("The entry is ");
System.out.println(entry);
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));
System.out.println(entry + " minus " +
anotherEntry + " is " + (entry - anotherEntry));
System.out.println(entry + " times " +
anotherEntry + " is " + (entry * anotherEntry));
System.out.println(entry + " divided by " +
anotherEntry + " is " + (entry / anotherEntry));
System.out.println("The remainder is " +
(entry % anotherEntry));
}
}

这是我的错误消息:

C:\User\Student\Desktop\mywork>javac DemoVariables3.java
DemoVariables3.java:16: error: cannot find symbol
System.out.println(anotherEntry);
                   ^

该错误消息在我的代码中重复了 12 次;任何帮助,将不胜感激。

编辑:我真的没有看到 anotherEntry 没有被定义,我认为这意味着一旦我启动应用程序最终用户会输入什么(我刚刚开始,所以如果我错了,我深表歉意)

Edit2:上帝我觉得很愚蠢,我只是没有为 anotherEntry 声明字符串;非常感谢您为我指出这一点!

4

0 回答 0