Java program to call an Instance Initializer Block using the anonymous object
// Java program to call an Instance Initializer Block
// using the anonymous object
class Sample {
{
System.out.println("Instance initializer block called");
}
Sample() {
System.out.println("Constructor called");
}
}
public class Main {
public static void main(String[] args) {
new Sample();
}
}
Output
Instance initializer block called
Constructor called