Home Java Java-get-example Java error class interface or enum excepted
Questions:Ask|Latest


 
 

Share on Google+Share on Google+

Java error class interface or enum excepted

Advertisement
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
Advertisements

Liked it!  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.

Posted on: November 3, 2008

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

Post your Comment


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

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...
ganga
June 25, 2012
please solve this

import java.net.*; 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); } } } }
bvsaikrishna
August 22, 2012
core java

error:ParamTest1.java:2: 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> //ParamTest1.java import java.awt.*; import java.applet.*; import java.net.*; 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); } }
Soniya
October 13, 2012
PSVM Comments

Nice Article
mansoor
November 10, 2012
java programming

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