I am new to java so when i was debugging a piece of code then i found out that the execution goes to constructor but before entering into the body of constructor it wen to the instance variable so can you please explain me the reason
public class TestExecution
{
int input1 = 5;
int input2 = 6;
TestExecution()
{
System.out.println(input1+"before main"+input2);
int input1 = 10;
int input2 = 11;
System.out.println(input1+"after main"+input2);
}
public static void main(String[] args)
{
TestExecution testExcution = new TestExecution();
}
}
Result was:
5beforemain6 10aftermain11