Others have indicated that class properties are initialized with default values ββfor you.
So, semantically, it makes no difference if you explicitly set them to 0 (or, for the properties of an object, set them to null.)
However, there may be a difference at the bytecode level. There is no guarantee that code that differs only in class properties that are implicitly and explicitly set by default will have exactly the same bytecode.
Older versions of the JDK are used to generate larger and longer code for explicit initialization, which was easy to verify with javap . (This fact was sometimes used as the basis for interview questions.) I did not check the latest JDK versions to make sure that this is still the case.
source share