English Deutsch Français Italiano Español Português 繁體中文 Bahasa Indonesia Tiếng Việt ภาษาไทย
All categories

As well in what situations would you want to use it and in what situations would you NOT want to use it? Please give simple examples.

Also how do they differ from normal methods?

2006-08-07 16:25:41 · 4 answers · asked by quackerjackets 1 in Computers & Internet Programming & Design

Im learning Java

2006-08-07 17:00:37 · update #1

4 answers

Static variables are used when
a. In a file context, restict the global-ness of a variable from the point of declaration to the end of the file. You cannot 'extern' the variable and use it within another file.
b. In a function context, when you want to retain the value of a variable across multiple function calls, without making the variable global.
c. In a class/struct context, when you want to store some value irrespective of the number of instances of the class instantiated.

Static Methods:
a. In a file context, it means that the function can be called only within the file scope.
b. In a class context, it means that you can invoke a method of a class without having to instantiate an object. However note that in static methods, you can only manipulate variables that are declared as static, and not other variables.

2006-08-07 16:42:02 · answer #1 · answered by swami060 3 · 0 0

You need to tell us which language you're using. For example, the meaning of static in C is significantly different from the meaning in Java.

2006-08-07 16:48:32 · answer #2 · answered by gunghoiguana 2 · 0 0

static means that it cannot be changed

2006-08-07 16:34:03 · answer #3 · answered by blainezee 2 · 0 0

google it and do specify which language u r referring too... there are quite alot...

;)good luckz

2006-08-07 17:08:06 · answer #4 · answered by zoha 3 · 0 0

fedest.com, questions and answers