-
Notifications
You must be signed in to change notification settings - Fork 45.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
接口和抽象类的区别是什么 #146
Comments
感谢您的回答! |
关于抽象类 |
jdk1.8后,接口方法可以有方法体,需要用default或static修饰。实现类无需重新。当然default方法重写也是可以的。如果一个类实现多个接口,多个接口有相同default方法,则子类必须重写该方法 |
请问,在jdk1.8中 |
@OverRide 是annotation,貌似不是必须的 |
看下RetentionPolicy的源码 注释是这样说的Annotations are to be discarded by the compiler. |
在JDK8中,接口也可以定义静态方法,可以直接用接口名调用。实现类和实现是不可以调用的。
如果同时实现两个接口,接口中定义了一样的默认方法,必须重写,不然会报错
The text was updated successfully, but these errors were encountered: