Missing paren

From JavaErrors

Jump to: navigation, search

The error

 Syntax error, insert ")" to complete something

can be triggered by several different mistakes, and can show in several different ways.

Missing parenthesis

The most straightforward and obvious way to get this error message is if you write out a method but forget a parenthesis, you can get this error.

WRONG

 Foo aFoo = new Foo();
 foo.bar(; // missing )

WRONG

 Foo aFoo = new Foo();
 foo.bar(); / balanced parens

Missing arguments

You can also get this error sometimes if you are missing arguments:


WRONG

 Foo aFoo = new Foo(x,); // missing argument

WRONG

 Foo aFoo = new Foo(x,y); // both arguments

This happens because the compiler is running along and gets confused when there isn't something after the comma, so basically aborts... and another part of the compiler is waiting to be told "I found a )!" When the ) doesn't show up, then that other part of the compiler gets upset and complains that it never got a ")".

This is a cascading error.