Java编译错误:解析时到达文件末尾
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/18884711/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Java compilation error : reached end of file while parsing
提问by user2771077
When I compile my code I keep getting this error. Also, before i get this error, my display only showed the largest number and not the smallest one. any help will be very much appreciated. thanks for your time.
当我编译我的代码时,我不断收到此错误。此外,在我收到此错误之前,我的显示器只显示最大的数字而不是最小的数字。任何帮助将不胜感激。谢谢你的时间。
LargestAndSmallest.java:51: reached end of file while parsing ?????????
} 0000 0000 0000 0000 0000 0000 ^ 1 error
LargestAndSmallest.java:51: 解析时到达文件末尾?????????
} 0000 0000 0000 0000 0000 0000 ^ 1 error
This is my code:
这是我的代码:
import java.util.Scanner;
public class LargestAndSmallest
{
public static void main(String[] args)
{
int input;
Scanner keyboard = new Scanner(System.in);
System.out.print("Enter an integer number or -99 to quit: ");
input = keyboard.nextInt();
int MIN_VALUE = 0;
int MAX_VALUE = 0;
while (input != -99)
{
if (input > MAX_VALUE)
{
MAX_VALUE = input;
}
else if (input < MIN_VALUE)
{
MIN_VALUE = input;
}
if (MAX_VALUE == -99)
{
System.out.print("\nYou did not enter any number");
}
else
{
System.out.print("\nLargest: " + MAX_VALUE);
System.out.print("\nSmallest:" + MIN_VALUE);
}
}
}
采纳答案by user2744515
You forgot a bracket try adding one like this
你忘记了一个括号尝试添加一个这样的
while (input != -99)
{
if (input > MAX_VALUE)
{
MAX_VALUE = input;
}
else if (input < MIN_VALUE)
{
MIN_VALUE = input;
}
}