Can we say Constructors are Methods in Java?

后端 未结 4 535
礼貌的吻别
礼貌的吻别 2021-01-29 15:57

As we know Java is an object oriented language. Everything is objects in Java. We also know that objects have something (instance variables / fields) and do something (methods).

4条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-01-29 16:23

    a constructor is used to initialize variables, it is not a method. you can however choose to create constructor, if you do not the JVM will create a default constructor.

提交回复
热议问题