Cureless - blog, works and personal site of Yoru

Cureless

Cureless is the online journal (blog) of Yoru, a Filipina, programmer, ex-military, an anime otaku, a casual DoTA and MMORPG gamer and a self-proclaimed artist - in short, a geeky nerd and a fan.
Take a peek at her occasional ramblings about random passions and life experiences, browse her archives and works.

email

flickr

Land and skyStranded since remingLittle piratesFriendly kids at the foot of Mayon

To err is human

Even the SCJP examiners overlooked the following:

Taken from SCJP reviewer

Like wha? I was totally troubled after reading the code above. How come the static methods are able to access the instance (non-static) variable? I re-read the previous chapter and typed and compiled the code on my own.

% javac Foo.java
Foo.java:11: non-static variable size cannot be referenced from a static context
System.out.println("size = " + size);
Foo.java:12: non-static variable size cannot be referenced from a static context
changeIt(size);
Foo.java:13: non-static variable size cannot be referenced from a static context
System.out.println("size after changeIt is " + size);
3 errors

Thankfully, it didn't compile. No debunking of previous "theories". It was only a typo. :P The variable should be declared with a static modifier.

Download FREE WordPress Themes

Download FREE WordPress Themes

Sponsored Links

  • Hire Me via PayPerPost Direct!