Static variable-static method and static block
static keyword
The static keyword in Java is mainly used for memory management. When a member is declared static, it can be accessed directly.To create a static member, the static keyword is used before its declaration.Block, variable, method and classes can use static keyword.
java buzzwords explanation
static variable and static method
in java have different types of variables are available
local,instance and static variable
In a class global variables are declared using the static keyword
Definition of object —>An object is programming entity and class is collection of object
Every class will be having variables and methods
If the variable declare as a static these static variable can be access into two ways
1 directly access—>If our program is in a single class You can directly access the variable
2 with the help of class name—->If your program is in multiple classes You can access the variable with the help of class name
similarly the static method also we can do directly access
if the program in single class
If there is more than one class, you can access
the static method by giving the class name
static block
Static blocks can be written in static keyword and curly braces.
whatever content written in static block can be executed by
default without any explicit call and if there is any reference
to the particular class
Comments
Post a Comment