Static
Static
Brajesh Raj
Index
Static variable
Program of the counter without static variable
Program of the counter with static variable
Static method
Restrictions for the static method
Why is the main method static?
Static block
Can we execute a program without main
method?
Introduction
The static keyword in Java is used for memory
management mainly. We can apply static keyword
with variables, methods, blocks and nested
classes. The static keyword belongs to the class
than an instance of the class.
Counter(){
count++;//incrementing value
System.out.println(count);
}
Counter2(){
count++;//incrementing the value of static variable
System.out.println(count);
}
A3.java
THANK YOU