-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx1RefMainV2.java
More file actions
36 lines (29 loc) · 895 Bytes
/
Copy pathEx1RefMainV2.java
File metadata and controls
36 lines (29 loc) · 895 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
29
30
31
32
33
34
35
36
package nested.anonymous.ex;
import java.util.Random;
public class Ex1RefMainV2 {
public static void hello(Process process){
System.out.println("프로그램 시작");
process.run();
System.out.println("프로그램 종료");
}
public static void main(String[] args) {
class Dice implements Process {
@Override
public void run() {
int randomValue = new Random().nextInt(6) + 1;
System.out.println("주사위 = " + randomValue);
}
}
class Sum implements Process {
@Override
public void run() {
for(int i = 1; i<= 3; i++){
System.out.println("i = " + i);
}
}
}
System.out.println("Hello 실행");
hello(new Dice());
hello(new Sum());
}
}