An enclosing instance of type 'identifier' is required
The compiler detected that an inner class definition tried to reference something outside of its scope. Examples of when this can occur are:
The following examples illustrate this error:
//This example illustrates the first error situation
public class Simple{
int x = 10;
static class InnerClass{
public void method1(){
int y = x; /*error: instance variable needed
to reference parent
variables. */
}
}
}
//This example illustrates the second error situation
class A{
int x;
}
class B{
//Do something meaningful here
class InnerClass{
void method1(){
int y = A.this.x;
/*error: no instance of A defined. Cannot use
the <classname.this.variable> syntax here.*/
}
}
}