解析编译错误时到达文件末尾
问题描述:
我是一个java编程初学者。我做错了:在解析时到达文件结尾
I am a java programming beginner. What did i do to get the error: reached end of file while parsing
import java.util.Scanner;
class eng{
public static void main(String[] args){
Scanner input = new Scanner(System.in);
String value;
String direct = "answer true or false to the following statement.";
String ques = "Twelve is greater than seven";
System.out.println(direct);
System.out.println(ques);
value = input.nextLine();
if ((value = "true")) {
System.out.println("you are correct");
} else {
System.out.println("you are wrong my friend");
}
}
答
- 在您错过代码的结尾添加另一个}
if((value = "true"))
不是检查字符串相等性的正确方法,并且存在语法错误。
is not a proper way to check string equality and has syntax error it should be
if(value.equals("true"))