Error List

Error List for the ‘JAVA-Compiler’ Category

Missing } brackets

Applies to:
NA

Description:
This is a syntax error and occurs when there are mismatched brackets in your program

Cause:
Brackets are not opened or closed in the right positions.

JAVA-Compiler ,

Missing class bracket

Applies to:
NA

Description:
This is a syntax error and occurs when there are mismatched class brackets in your program

Cause:
The final } bracket of a class is omitted.

JAVA-Compiler ,

} expected

Applies to:
NA

Description:
This is a syntax error and occurs when the class method is written in a wrong format

Cause:
There is no closing } at the end of the class.

class HelloWorld {
public static void main(String[] args)
{
System.out.println(“Hi”);
}

JAVA-Compiler ,

Identifier expected

Applies to:
NA

Description:
A variable name or type is expected.

Cause:
a. Method arguments are specified incorrectly
b. Syntax error
System..out.println(“This is a test”);
c. A variable used is not yet declared


JAVA-Compiler , ,

Invalid method declaration; return type required

Void methods cannot return a value

Applies to:
NA

Description:
This is a syntax error and occurs because of the mismatch in the method declaration and its return value.

Cause:
A return value is included in a method of type void:
public void test() {
return 10;
}

JAVA-Compiler ,

Return required

Applies to:
NA

Description:
This is a syntax error and occurs when “return” is omitted in methods that return a value

Cause:
a. The statement “return” is omitted in the declaration of a return type for a method.
B. Return cases are not written in all cases for methods having mulitiple pathways like if statements and loops:
public String myTest(int x)
{
if (x >= 100)
return “A”;
else if (x >= 50)
return “B”;
else if (x >=20)
return “C”;
}

JAVA-Compiler ,

Incompatible type for declaration can't convert yy to zz

Applies to:
NA

Description:
This is a syntax error and occurs when the data that is passed is not of the type expected and Java can’t find a way to convert the type.

Cause:
a. A parameter passed is not of the right type.
b. A data of type character is mistakenly written as a string by using double quotes on it.
char x = “x”;

JAVA-Compiler , , , , ,

No constructor matching yy found in class zz

Applies to:
NA

Description:
The compiler cannot detect the compiler being called

Cause:
a. The constructor is called with incorrect number of parameters
b. The default constructor is being called implicitly

JAVA-Compiler

NoSuchMethodError

Applies to:
NA

Description:
The main method is missing or the signature is incorrect

Cause:
The keyword “static” is missed out:
public void main (String[] args)

Or the main method is incorrectly written as follows:
a. private static void main (String[] args)
b. public static int main (String[] args)
c. public static void main (String args)


JAVA-Compiler