📄 ex21.java
字号:
// innerclasses/Ex21.java
// TIJ4 Chapter Innerclasses, Exercise 21, page 367
/* Create an interface that contains a nested class that has a static method that
* calls the methods of your interface and displays the results. Implement your
* interface and pass an instance of your implementation to the method.
*/
interface In {
String f();
String g();
class Nested {
static void testIn(In i) {
System.out.println(i.f() + i.g());
}
}
}
public class Ex21 implements In {
public String f() { return "hello "; }
public String g() { return "friend"; }
public static void main(String[] args) {
Ex21 x = new Ex21();
In.Nested.testIn(x);
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -