Files
Hui-s-notebook/logseq-java/pages/构造器.md
2024-02-02 00:12:49 +08:00

21 lines
544 B
Markdown
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
- 作用
- 配合 [[new]] 关键字,创建对象的实例
- 编译器会自动的在类中,给每个类产生一个无参构造方法
- 自己定义
- ```java
public Book(){
}
```
- 方法名用类名一致
- 无任何返回值无void
- [[无参构造器]]
- [[有参构造器]]
- 作用
- ((62539750-497b-42e9-965e-d1d4ddf2888a))
id:: 6253975b-b401-45c2-90c9-693d59ebc80a
- 注意
- 写有参时要先写一个无参构造器
- 编译器发现构建了有参构造器就不会自动创建无参构造器
-
-