You can't access a private variable (static or otherwise) from another class. If you saw something similar in a tutorial, then the chances are it was actually accessing it from the same class. For instance, if you move the main() method to the usingStatic class, then it will work.

(Oh, and do call it UsingStatic rather than usingStatic, won't you? Life is much easier if you follow the standard conventions.)

AnujS Sharma
Greenhorn

Joined: Jul 30, 2011
Posts: 15

posted Sep 01, 2011 06:52:38

0

I am pretty sure that the static variable was being called from another class, but maybe I am wrong.