Hi, I've a question about this code:
public class Test {
public Test(){}
public static void main(String args[])
{
System.out.println(new Test().i);
}
int i;
}
The Java book I'm consulting says that when you provide a parameter less constructor, you replace the Java-provided default constructor. It also states that the Java-provided default constructor initialises all attributes to a default value for example zero for an integer.
However, if the above code is really replacing the default constructor, then how is int i being set to zero?
I suppose in a way this seems a weird question, it's just I'm trying to get a good understanding of the basics.
Thanks.