The static keyword in Java programming language
- Home
- Keyword in Java
- The static keyword in Java programming language
- On
- By
- 0 Comment
- Categories: Keyword in Java
The static keyword in Java programming language
The static keyword in java language
We will describe in this tutorial about The static keyword in java language
In java programming language static is a keyword which is used mainly for memory management and it is an access modifier. Static can be applied in Java’s: field , method , inner class and nested class. Static is a reserve word in the Java programing language. Static key word can be used in various way in Java:
Static keyword can be used in:
- Variable
- method
- block
- nested class
Advantage of static keyword
It makes the program’s memory efficient (save memory).
Static variable
The static variable can be used to refer to the common property of all objects.
Declaration
Syntax of static variable
public static <variable_name>
Example
static string name="kannan";
Static method
A static methods belongs to the class rather than object of a class.
Declaration
Syntax of static Method
public static void method_name() { ................. ................. }
Example
static void run(){ //codes }
program example static variable
There are other Java language keywords that are similar to this keyword
Suggested for you
Usage of this statement in the Java language