This week's book giveaway is in the OO, Patterns, UML and Refactoring forum. We're giving away four copies of Refactoring for Software Design Smells: Managing Technical Debt and have Girish Suryanarayana, Ganesh Samarthyam & Tushar Sharma on-line! See this thread for details.
Ok so I wrote this code below to look at statics, inheritance and access modifiers and once again Java totally has me scratching my head..
We are told that variables without access modifiers default to access from only within the package.. this is why you have protected variables, so that subclasses is other packages can access those variables.
So check this out.. this completely baffles me.
in one file I have the following:
In another file I have the following.. This is located in the com\thing\mine subfolder and classpath defaults to \.\ (Yep, Windows XP)
Why can I access thing from a different package, different class when it's static??? Why can I access it from a different package when it's access is package only???
This code compiles, runs and the output is:
setthing to 5? 5
Doin' Java to be one of the cool kids.
I usually use Perl;