Hi All.
Here is a source code to understand the scope of a local inner class.
class A { protected char a = 'a';}
class B { protected char b = 'b';}
public class LocalClass extends A
{
private char c = 'c';
public static char d = 'd';
public void createLocalObject(final char e)
{
final char f = 'f';
int i = 0;
class Local extends B
{
Local L = new Local();
char g = 'g';
public void printVars()
{
System.out.println(g);
System.out.println(f);
System.out.println(e);
System.out.println(d);
System.out.println(c);
System.out.println(b);
System.out.println(a);
}
}
}
public static void main(
String arg[])
{
LocalClass LC = new LocalClass();
LC.createLocalObject('e');
LocalClass.Local.printVars();
}
}
The compiler is not able to refer to "Local" in the last line of the main method.
LocalClass.Local.printVars();
^
Q1. What the mistake in the code..?
Q2. Is the char d accessible in Local, d being public static?
Regards,
Rekha