System.out.println("init"); this statement is not within static block and not in any function or constructor, but still java doesn't give any error or warning and prints it before constructor sysout. why ?
public class A {
public A()
{
System.out.println("A()");
}
public void print(int a) {
System.out.println("integer");
}
{
System.out.println("init");
}
}
public class TestA {
public static void main(String args[]) {
A a = new A();
a.print(new Integer(1));
}
}
Output :
init
A()
integer