Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why static fields are called "static"?

Tags:

java

What is the reason behind using the word "static" in "static variables" or "static methods"?

I'm not asking for the definition of "static", just asking why it is called so.

like image 901
securitypolicymanager Avatar asked Dec 10 '22 10:12

securitypolicymanager


1 Answers

It's a hold over from C++ and C before that. In the C context, one of its meanings was for variables that keep their value between invocations. I presume that's where 'static' comes from - it doesn't reset the value (as opposed to a const where the value cannot change)

like image 186
Kaffiene Avatar answered Dec 28 '22 20:12

Kaffiene