create A Simple Static Method With A Constructor in Java
create A Simple Static Method With A Constructor in Java
create A Simple Static Method With A Constructor in Java
static
{
System.out.println("The Static");
}
Static_Ex0()
{
System.out.println("The Constructor");
}
}
class MainClass
{
new Static_Ex0();
}
}
//Output
The Static
The Constructor
Static_Ex3() {
System.out.println("The Constructor");
}
void Method() {
System.out.println("The Method");
}
}
class MainClass {
obj.Method();
}
}
//Output
The Static
The Constructor
The Method
static
{
System.out.println("The Static");
}
Static_Ex2()
{
System.out.println("The Constructor");
}
void Method()
{
System.out.println("The Method");
}
}
class MainClass
{
static
{
System.out.println("The MainClass Static");
}
public static void main(String args[])
{
Static_Ex2 obj = new Static_Ex2();
obj.Method();
}
}
//Output
Static_Ex1() {
class MainClass {
new Static_Ex1();
}
}
//Output
The Static Variables are :
int Variable : 5
Static int Variable : 5
int Variable : 5
Static int Variable : 15