What's the access modifier of the default constructor in java?

前端 未结 3 1780
一整个雨季
一整个雨季 2020-12-23 14:15

We all know that if we don\'t specifically define a constructor, the compiler inserts an invisible zero-parameter constructor. I thought its access modifier was public, but

3条回答
  •  不知归路
    2020-12-23 15:05

    In addition to what Jon pretty well stated, here is an image example, for the visual guys.

    If there is no constructor in a class, compiler automatically creates a default constructor.

    Here is an example that successfully depicts the above rule:

    For further reference, please refer here.

提交回复
热议问题