Java Program using static variables methods and blocks
In this program, You will learn how to implement static variables methods and blocks in java.
static int x;
static void display() {
//statement
}
static {
//statement
}
Example: How to implement static variables methods and blocks in java.
class Main {
static int x = 10;
static {
System.out.println("static block is called here");
}
static void display() {
System.out.println("x value is :" + x);
}
public static void main(String args[]) {
display();
}
}
Output:
static block is called here
x value is :10