P
Paul Carey
Hi
I just noticed the following when studying for the scjp. Does anyone
know if there's any reason for the compiler errors generated by the
commented line below as to me it doesn't seem consistent with the
other ways of accessing static variables and methods.
Thanks
Paul
public class StaticAccess
{
static int i = 0;
static int method()
{
return 5;
}
static class StaticNested
{
int nestedMethod()
{
return 10;
}
}
void testAccess()
{
int a = StaticAccess.i;
int b = this.i;
int c = StaticAccess.method();
int d = this.method();
StaticNested sna = new StaticAccess.StaticNested();
// StaticNested snb = new this.StaticNested();
StaticNested snc = new StaticNested();
}
}
I just noticed the following when studying for the scjp. Does anyone
know if there's any reason for the compiler errors generated by the
commented line below as to me it doesn't seem consistent with the
other ways of accessing static variables and methods.
Thanks
Paul
public class StaticAccess
{
static int i = 0;
static int method()
{
return 5;
}
static class StaticNested
{
int nestedMethod()
{
return 10;
}
}
void testAccess()
{
int a = StaticAccess.i;
int b = this.i;
int c = StaticAccess.method();
int d = this.method();
StaticNested sna = new StaticAccess.StaticNested();
// StaticNested snb = new this.StaticNested();
StaticNested snc = new StaticNested();
}
}