Java error class interface or enum excepted

Ads
 

Java error class interface or enum excepted

Java Error class interface or enum excepted are the class of java error that occurred when a programmer placed a brace in improper place or braces are not properly closed.

Java Error class interface or enum excepted are the class of java error that occurred when a programmer placed a brace in improper place or braces are not properly closed.

Java error class interface or enum excepted

     

Java Error class interface or enum excepted are the class of java error that occurred when a programmer placed a brace in improper place or braces are not properly closed.

Understand with Example

In this Tutorial we want to describe you a code that explain you java error class or enum excepted ,For this we have a class name'InterfaceEnumexcepted',Inside the main method we have taken an instance of Date class.

 

 

Let us look to the method used in this class-

calendar.getInstance This method returns you a calendar object initialized with the current time and date.
setTime(date ) This method returns you the time set with the calendar date.
StringBuffer  This method is a mutable one that can be changed according to specified condition by calling a certain method.
append  This method returns you the concatenates the representation in string of any  type of data in  the end of the invoking of string buffer.
System.out.println This is used to display the current date.
Tostring Once the concatenation has been done, the compiler invoke  to to String( ) that turn  the modifiable StringBufer  into a constant String.

InterfaceEnumexcepted.java


import java.net.*;
import java.util.*;

public class InterfaceEnumexcepted {

  public static void main(String args[]) {

  Date date = new Date();
  Calendar cal = Calendar.getInstance();

  cal.setTime(date);

  StringBuffer sb = new StringBuffer("");

  sb.append(cal.get(Calendar.DAY_OF_MONTH));
  sb.append(".");
  
  sb.append((cal.get(Calendar.MONDAY1));
  sb.append(".");
  
  sb.append(cal.get(Calendar.YEAR));
  sb.append(" ");
  
  
  System.out.println("Today's Date is :"+sb.toString());
 } }
}
 

On the execution of the above code the compiler show a class,enum interface is expected as braces are not properly closed.
Output

Compiling source file to /home/girish/NetBeansProjects/errors/build/classes
/home/girish/NetBeansProjects/errors/src/
InterfaceEnumexcepted.java:
28: class, interface, or enum expected
}

To resolve this problem you have to check wheather curly braces are properly closed or not

Download code

Ads

Ads