Static variable in Java

public class StaticDemo1 {
	static int x = 10;
	static int count = 0;
	int y = 10;
	StaticDemo1() {
		count++;
	}
	StaticDemo1(int i) {
		this();
	}
	static void disp() {
		System.out.println(x);
		// System.out.println(y);
	}
	void disp1() {
		System.out.println(x);
		System.out.println(y);
	}
	public static void main(String[] args) {
		System.out.println(StaticDemo1.x);
		StaticDemo1 a = new StaticDemo1();
		System.out.println(a.x);
	}
}

Download

Access modifiers in Java

Complete abstract Example
Complete final Example
Static Block
Static variable
Static method


Write your Comment

Name :
Email Id : [ We will not publish your email id ]
Your Comment : [ Maximum 200 chars ]
Enter Security code