zeze-231
zeze-231

Reputation: 3

Reached end of file while parsing compilation error

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

Upvotes: 0

Views: 284

Answers (3)

Mr.yu
Mr.yu

Reputation: 11

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

Upvotes: 0

rumman0786
rumman0786

Reputation: 1310

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

Upvotes: 2

Michael Albers
Michael Albers

Reputation: 3779

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

Upvotes: 0

Related Questions