ClustrMaps

The roadrunner is back as never before! See also: My homepage or my very obsolete site
If by any means entries in my blog are considered to be harmful or damaging, please let me know (add comment) or just mail me. In this (unhopely) case I will remove or change the contents.

Saturday, August 18, 2007

Still struggling with Java?
Me too (who isn't?).
In this particular case, it's about static methods, accessing class variables.
A lesson learned: do not add state to classes with static methods.
Concurrency will lead to problems!

See for instance http://www.javaworld.com/javaworld/javaqa/2001-11/03-qa-1121-mrhappy.html
When you declare a method as static, you define that method as being a class method. A class method applies to the class as opposed to any particular instance. The behavior instigated by a class method does not rely on the state of a particular instance. In fact, a static method cannot rely on an instance's state since static methods lack access to this reference. Instead, the behavior of a class method either depends on a state that all objects share at the class level, or is independent of any state at all.

Nice name in the URL: mrhappy!

Actually it's Mr. Happy Object, see
http://www.javaworld.com/javaqa/2002-03/01-qa-0315-happyevent.html?page=1
Woe to he who angers MrHappyObject!

No comments: