forked from BruceEckel/OnJava8-Examples
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathJim.java
More file actions
28 lines (25 loc) · 745 Bytes
/
Copy pathJim.java
File metadata and controls
28 lines (25 loc) · 745 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
// interfaces/Jim.java
// (c)2020 MindView LLC: see Copyright.txt
// We make no guarantees that this code is fit for any purpose.
// Visit http://OnJava8.com for more book information.
import java.util.*;
interface Jim1 {
default void jim() {
System.err.println("Jim1::jim");
}
}
interface Jim2 {
default void jim() {
System.err.println("Jim2::jim");
}
}
public class Jim implements Jim1, Jim2 {
@Override
public void jim() { Jim2.super.jim(); }//self-note: 为了解决多个implements中各个接口的签名相同而导致的命名冲突(返回类型不是方法签名的一部分,因此不能用来区分方法),的问题
public static void main(String[] args) {
new Jim().jim();
}
}
/* Output:
Jim2::jim
*/