Static Variables in Java (Hindi) || Static Keyword in Java
seen from Japan
seen from Israel
seen from United States

seen from United States

seen from United States
seen from United States
seen from South Korea

seen from T1
seen from United States

seen from United States
seen from United States
seen from Moldova
seen from United States

seen from Israel
seen from United States

seen from United States
seen from India

seen from United States
seen from China
seen from South Korea
Static Variables in Java (Hindi) || Static Keyword in Java
Learn Java Programming - Introduction to the Static Modifier
The static keyword can be applied to variables, methods, blocks, and nested classes. Don't worry about blocks and nested classes yet, I will cover them in future tutorials. In a nutshell, when the static modifier is applied to a member, that member is shared between all objects. In addition, there is no need to create an instance of a class to access a static member, but you can if you want to. The static modifier has many purposes, so the best way to begin explaining what static does is to apply it to a simple variable and use a hypothetical example.
Two faces of STATIC
By default all functions are implicitly declared as extern, which means they're visible across translation units. But when we use static it restricts visibility of the function to the translation unit in which it's defined. So we can say Functions that are visible only to other functions in the same file are known as static functions. Let use try out some code about static functions. main.c #include "header.h" int main() { hello(); return 0; } func.c #include "header.h" void int hello() { printf("HELLO WORLD\n"); } header.h view plainprint? #include static int hello(); If we compile above code it fails as shown below view plainprint? $gcc main.c func.c header.h:4: warning: "hello" used but never defined /tmp/ccaHx5Ic.o: In function `main': main.c:(.text+0x12): undefined reference to `hello' collect2: ld returned 1 exit status It fails in Linking since function hello() is declared as static and its definition is accessible only within func.c file but not for main.c file. All the functions within func.c can access hello() function but not by functions outside func.c file. Using this concept we can restrict others from accessing the internal functions which we want to hide from outside world. Now we don't need to create private header files for internal functions. Note: For some reason, static has different meanings in in different contexts. 1. When specified on a function declaration, it makes the function local to the file. 2. When specified with a variable inside a function, it allows the variable to retain its value between calls to the function. See static variables. It seems a little strange that the same keyword has such different meanings...