Reached end of file while parsing compilation erro

2019-03-06 07:16发布

问题:

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");              
    }
}

回答1:

  1. Add Another "}" at end of your code you missed one

2.There is another error in your code

if((value = "true"))

is not a proper way to check string equality and has syntax error it should be

if(value.equals("true"))


回答2:

You're simply missing a closing brace }. From what the compiler sees you never closed the brace after class eng{



回答3:

Please re-indent/re-format your code first. Maybe you'll find a missing end brace "}".