forked from akash-coded/C133-Java
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathNestedInterface.java
61 lines (50 loc) · 1.46 KB
/
NestedInterface.java
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
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
interface Doable {
void doSomething();
interface AlsoDoable {
void doSomething(int x);
void doSomethingElse();
}
}
class Outer {
static int x = 10;
int y = 20;
protected interface Inner {
void show();
static void displayX() {
System.out.println("Printing from static function of nested interface" + x);
}
default void displayY() {
Outer obj = new Outer();
System.out.println("Printing from default function of nested interface" + obj.y);
}
}
}
class Implementor implements Doable, Doable.AlsoDoable, Outer.Inner {
@Override
public void doSomething() {
System.out.println("Printing something on behalf of the outer interface");
}
@Override
public void doSomething(int x) {
System.out.println("Printing something on behalf of the inner interface");
}
@Override
public void doSomethingElse() {
System.out.println("Printing something else on behalf of the inner interface: ");
}
@Override
public void show() {
System.out.println("Printing something else on behalf of the interface inside a class: ");
}
}
public class NestedInterface {
public static void main(String[] args) {
Implementor i = new Implementor();
i.doSomething();
i.doSomething(5);
i.doSomethingElse();
i.show();
Outer.Inner.displayX();
i.displayY();
}
}