Non Static Variables

Can be accessed only by creating an instance.
It will be not be updated when a new instance of the object is created.

public class NonStaticVariables {
 public NonStaticVariables() {
        instancecount++;
    }

    private   int instancecount;
    public static void main(String args[]){
        NonStaticVariables nsv=new NonStaticVariables();
    System.out.println(nsv.instancecount);
  NonStaticVariables nsv1=new NonStaticVariables();
    System.out.println(nsv1.instancecount);

    }

}

Comments

Popular posts from this blog

defining functions clojure

How to retain the space of the td after hidding it in Jquery

Integrating Struts2 with Spring Security using Custom Login Form