构造器:(构造器本质上是构造方法)
和类名相同
没有返回值
构造器的作用
创建对象
初始化对象的值
一个类即使什么都不写(指没有属性,没有方法),它也会存在一个方法:无参的构造方法
实例化:本质上是通过new实例化了一个对象,分配了内存
使用new关键字,本质上是在调用构造器
注意点
定义有参构造之后,如果想使用无参构造,就必须显式定义无参构造