Static Members in Java

Whenever any member variable of class is declared as static then that member variable is known as static member variable.

Whenever any method of class is declared as static then that method is known as static method. Static block or static method can directly access only the static members of its own class and cannot directly access non static members of its own class.

            class Example1

                        {

                             int a=10;

                             public static void main(String arg [ ])

                                    {

                                    System.out.println(“value=”+a);

                                    }

                        }

                        In the above example variable ‘a’ is non static member variable and static

Leave a Reply

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