Share on Google+Share on Google+

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


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.

import java.util.*;

public class InterfaceEnumexcepted {

  public static void main(String args[]) {

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


  StringBuffer sb = new StringBuffer("");

  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.

Compiling source file to /home/girish/NetBeansProjects/errors/build/classes
28: class, interface, or enum expected

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

Download code


Posted on: November 3, 2008 If you enjoyed this post then why not add us on Google+? Add us to your Circles

Share this Tutorial Follow us on Twitter, or add us on Facebook or Google Plus to keep you updated with the recent trends of Java and other open source platforms.

Discuss: Java error class interface or enum excepted   View All Comments

Post your Comment

Your Name (*) :
Your Email :
Subject (*):
Your Comment (*):
  Reload Image
March 5, 2012

public class Hello{} public static (void mymethod() ( System.out.println("Hello World!!")
Dipanjan Dutta
March 28, 2012
Java error class interface or enum excepted

Previously the topic was greatly discussed...but above those things we can do one thing that keep our coding portion in the try - catch block which prevents such error...
June 25, 2012
please solve this

import*; class Square { protected double X; Square(double x) { this.x=x; } void area() { system.out.println("area of Square= "+(x*X)); } } class Rectangle extends Square { private double y; Rectangle(double a, double b) { super(a); y=b; } void area() { system.out.println("area of rectangle= "+(x*y)); } } Square obj1=new Square(10.5); obj1.area(); Rectangle obj2=new Rectangle(10.5,11.5) obj2.area(); class Area { public static void main(String args[]); { system.out.println("area x="+x); system.out.println("area y="+y); } } } }
August 22, 2012
core java class, interface, or enum expected <applet code="ParamTest1" width=300 height=400> program: //ParamTest1.html <applet code="ParamTest1" width=300 height=400> <param no=sno value="101"> <param name=sname value="satya"> </applet> // import java.awt.*; import java.applet.*; import*; public class ParamTest1 extends Applet { String str1,str2,str3,str4; URL url1,url2; public void init() { str1=new String(); str2=new String(); } public void start() { str1=getParameter("sno"); str2=getParameter("sname"); repaint(); url1=getCodeBase(); url2=getDocumentBase(); str3=url1.toString(); str4=url2.toString(); repaint(); } public void paint(Graphics g) { g.drawString(str1,50,50); g.drawString(str2,100,100); g.drawString(str3,150,150); g.drawString(str4,200,200); } }
October 13, 2012
PSVM Comments

Nice Article
November 10, 2012
java programming

i want more information about the tips to java languages. how the error to clear and more details.