-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathEx1Main.java
More file actions
33 lines (25 loc) · 840 Bytes
/
Copy pathEx1Main.java
File metadata and controls
33 lines (25 loc) · 840 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
package lambda.start;
import java.util.Random;
public class Ex1Main {
public static void main(String[] args) {
helloDice();
helloSum();
}
private static void helloDice() {
long startNs = System.nanoTime();
// 코드 조각 시작
int randomValue = new Random().nextInt(6) + 1;
System.out.println("주사위 = " + randomValue);
// 코드 조각 종료
long endNs = System.nanoTime();
System.out.println("실행 시간: " + (endNs - startNs) + "ns");
}
public static void helloSum(){
long startNs = System.nanoTime();
for (int i = 1; i <= 3; i++) {
System.out.println("i = " + i);
}
long endNs = System.nanoTime();
System.out.println("실행 시간: " + (endNs - startNs) + "ns");
}
}