The C language alows to use the static keyword :
(.. )'static' can also be defined within a function. If this is done, the
variable is initalised at compilation time and retains its value between
calls.
Is there any equivalent of this feature in java ?
Eric Sosman - 07 Jul 2007 14:13 GMT
> The C language alows to use the static keyword :
> (.. )'static' can also be defined within a function. If this is done, the
> variable is initalised at compilation time and retains its value between
> calls.
> Is there any equivalent of this feature in java ?
No exact equivalent. A reasonably close approximation
is a class variable:
class Thing {
// initialized when Thing class is loaded,
// retains last-stored value until program
// exits or class is unloaded, whichever
// comes first:
static Whatever what;
...
}

Signature
Eric Sosman
esosman@ieee-dot-org.invalid
Roedy Green - 07 Jul 2007 16:29 GMT
>The C language alows to use the static keyword :
>(.. )'static' can also be defined within a function. If this is done, the
>variable is initalised at compilation time and retains its value between
>calls.
> Is there any equivalent of this feature in java ?
See http://mindprod.com/jgloss/static.html
Java has static variables and methods, just like C++. However, it
does not have local static variables. You have to use class statics
instead and use a naming convention that suggests they are intended to
be used by only a single method.
--
Roedy Green Canadian Mind Products
The Java Glossary
http://mindprod.com