The constructor is empty, but is the instance variable still initialized?

I am new to java and I doubt the initialization of the object.

What I know now:

Constructors are used to initialize instance variables, and if we do not explicitly code the constructor, a default constructor is provided that automatically provides default values ​​for instance variables, such as 0 for int, etc.

My question is: How does the following code work (I did not initialize the instance variable)?

I tried the base code as follows:

public class hello{

int i;   //Instance variable
         public hello()
         {
         //Constructor is empty!!!
        }


public static void main(String args[])
    {

  System.out.println(new hello().i);


}
}

And the result was 0, but how? I did nothing in the constructor, and since I explicitly encoded the constructor, the default constructor should not be called (I know that I have the wrong concept, so please correct me).

, , . !

+4
3

, , .

:

Type                          Default Value
boolean                          false
byte                            (byte) 0
short                           (short) 0
int                                 0
long                                0L
char                             \u0000
float                              0.0f
double                             0.0d
object reference                   null

,

System.out.println(new hello(). i);

, , new . JVM .

, , JVM [IIB] .

+2

. . ( 0 int) .

:

boolean -> false
double -> 0.0D
[any object reference incl. String] -> null
+8

, . - , , . int i , ​​ . int 0.

+5

All Articles