Static Member Variable in Java

public class StaticMemberVariable{
        public static void main(String[] args) {
                ObjectCounter object1 = new ObjectCounter();
                ObjectCounter object2 = new ObjectCounter();
class ObjectCounter
         * Static members are class level variables and shared by all the objects
         * of the class.
         * To define static member, use static keyword
         * e.g. static int i=0;
         * Please note that static member variables can be accessed inside
         * non static methods because they are class level variables.
        static int counter=0;
        public ObjectCounter(){
                /*increase the object counter. Since only one varible is shared between
                 * all objects of this class, it always return number of objects till now.
        //returns number of objects created till now
        public int getNumberOfObjects(){
                return counter;