Link to home
Start Free TrialLog in
Avatar of yattias
yattias

asked on

static

Can anyone tell me what exactly Static means and when it should be used.  I kinda know when to use it but I am not sure I quite get the concept of it.

thanks
Avatar of sciuriware
sciuriware

static means: global (always present) for a variable.
                    accessing static variables for a method.
                    to be executed at startup for a block {}

Example:     static int count = 0;    // to count objects of this kind, 0 == no objects, still a variable,
                  static void counter() { ++ count; }  // to access this variable.

;JOOP!
Avatar of yattias

ASKER

I am not so sure I fully understand your definition of static.  Could you be more specific?
ASKER CERTIFIED SOLUTION
Avatar of Siva Prasanna Kumar
Siva Prasanna Kumar
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Basically its a member of the class for instantiating or using which you don't need to create objects of the class.

Explained here: http://www.mindprod.com/jgloss/static.html 
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Yes, you can use them for utilities (where you would expect the same result from a method and you don't need any instance data-members), and static is also made use of in the singleton design pattern.