Skip to content

Commit 386bac0

Browse files
authored
Update: 接口和抽象类的区别是什么
Java 8 开始接口方法可以有默认实现
1 parent 8583d26 commit 386bac0

File tree

1 file changed

+1
-1
lines changed

1 file changed

+1
-1
lines changed

Java相关/Java基础知识.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -225,7 +225,7 @@ String 中的对象是不可变的,也就可以理解为常量,线程安全
225225

226226
## 17. 接口和抽象类的区别是什么
227227

228-
1. 接口的方法默认是 public,所有方法在接口中不能有实现,抽象类可以有非抽象的方法
228+
1. 接口的方法默认是 public,所有方法在接口中不能有实现(Java 8 开始接口方法可以有默认实现),抽象类可以有非抽象的方法
229229
2. 接口中的实例变量默认是 final 类型的,而抽象类中则不一定
230230
3. 一个类可以实现多个接口,但最多只能实现一个抽象类
231231
4. 一个类实现接口的话要实现接口的所有方法,而抽象类不一定

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy