Class or interface declaration expected

  • Share
  • Share

Applies to:
NA

Description:
This is a syntax error and occurs when keywords such as “class” or “int” are not found by the compiler or when there is code outside of a class declaration.

Cause:
a. Keywords are capitalized
b. Objects are declared at the start of the class and were mistakenly placed before the class has started.
Example:
String test = new String();
public class TestError
{
// Your code here
}


JAVA-Compiler , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , , ,

  1. admin
    March 9th, 2009 at 18:22 | #1

    Identify Java keywords and make sure that they are spelled correctly and are not capitalized.

  2. admin
    March 9th, 2009 at 18:22 | #2

    Place codes inside of a class declaration.

    Example:
    public class TestErrror
    {
    String test = new String();
    //Your code here
    }

  1. No trackbacks yet.