Learning Java – (Video 6) Tutorial Series – static keyword

This is sixth video in the series of Learning Java, In this video static methods and class fields are explained.

Difference between static and non static (instance variable) methods explained.

If you feel this video is useful, Please share it with your friends on Facebook, twitter Google plus etc.

Code developed in this tutorial provided below:

 * @author Niranjan
public class ClassA {

	public static int a = 10;
	public int b = 5;
	 * @param args
	public static void main(String[] args) {
		// TODO Auto-generated method stub

		// Create instance of ClassA
		ClassA obj = new ClassA();
	public static void methodAdd(){
		System.out.println("I am inside methodAdd");
		a = 4;
		System.out.println("Value of a = "+a);
		// Create instance of ClassA
		ClassA obj = new ClassA();
		obj.b = 3;
		System.out.println("value of b = "+obj.b);
	public void methodSub(){
		System.out.println("I am inside methodSub");


For further reading refer Java Programming Category posts.

Share this post

Learning Java Static Keyword Example
Tagged on:     

Leave a Reply

Your email address will not be published. Required fields are marked *