Rotate your phone or change to desktop for better experience

Rotate your phone or change to desktop for better experience

Pgm 6 || Program with class variable that is available for all instances of a class. Use static variable declaration. Observe the changes that occur in the objects member variable values.

 public class Pgm6

{

static int count=0;

int n=0;

Pgm6()

{

count++;

System.out.println("Static Variable="+count);

n++;

System.out.println("NoN-Static Variable="+n);

}

public static void main(String args[])

{

Pgm6 c1=new Pgm6();

Pgm6 c2=new Pgm6();

Pgm6 c3=new Pgm6();

}

}

Post a Comment

0 Comments