Java Static Variable, Method, Object with Examples
Get Job-ready: Java Course with 45+ Real-time Projects! - Learn Java
Program 1
class Abc
{
static int count=0;
static
{
System.out.println("This is static block");
}
Abc()
{
System.out.println("This is constructor");
count++;
}
static void display()
{
System.out.println(count);
}
}
class TestStatic
{
public static void main(String args[])
{
System.out.println("Hello");
// Abc.display();
// Abc A1=new Abc();
// Abc A2=new Abc();
// Abc A3=new Abc();
// Abc A4=new Abc();
// Abc A5=new Abc();
}
}
Did you know we work 24x7 to provide you best tutorials
Please encourage us - write a review on Google

