Java error reached end of file while parsing

Java Error reached end of file while parsing occurred when a programmer do not close the class braces properly.

Java error reached end of file while parsing

Java error reached end of file while parsing

     

Java Error reached end of file while parsing  occurred when a programmer do not close the class  braces properly.

Understand with Example

In this Tutorial we want to describe you a code that help you in understanding  java error reached end of file while parsing ,In this code we want to display Time in hour, minute and second. For this we have a class name Reachedendof filewhileparsing,Inside this class we have a main method that declare a string, format name variable. We create an instance of class date and assign to a memory. The current hour, minute and second  is store in a variable f,that is further used to call format and date object passed as parameter in string variable. The System.out.println is used to display the time from the string. But on execution the code show an error i.e java error reached end of file while parsing as the class closing braces is not specified. Reachedendoffilewhileparsing.java


import java.text.*;
import java.util.Date;

public class Reachedendoffilewhileparsing {

  public static void main(String args[]) {

  String string;
  Format f;
  Date date = new Date();

  f = new SimpleDateFormat("hh:mm:ss ");
  string = f.format(date);
  System.out.println("Time is : " + string);

  }

Output

Compiling source file to /home/girish/NetBeansProjects/errors/build/classes
/home/girish/NetBeansProjects/errors/src/
Reachedendoffilewhileparsing.java:
17: reached end of file while parsing

  }
error
BUILD FAILED (total time: seconds)

To resolve this error you have to close the class properly by giving brace.

Download code