constructor call java code example
Example 1: calling this in constructor java
In Java another constructor of the same class can be called from a
constructor via this().
Note however that this has to be on the first line.
Example 2: constructor in java
public class ConstructorDemo
{
int a;
ConstructorDemo()
{
a = 26;
}
public static void main(String[] args)
{
ConstructorDemo obj = new ConstructorDemo();
System.out.println(obj.a);
}
}