-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathAutoBoxing.java
More file actions
28 lines (22 loc) Β· 844 Bytes
/
Copy pathAutoBoxing.java
File metadata and controls
28 lines (22 loc) Β· 844 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
package Chapter2.Day6;
public class AutoBoxing {
public static void main(String[] args) {
long before = System.currentTimeMillis();
Long sum = 0l;
for (int i = 0; i < Integer.MAX_VALUE; i++) {
sum += i;
}
System.out.println("autoboxing : " + (System.currentTimeMillis() - before));
/**
* μ€ν λ°μ± λν λΆνμν κ°μ²΄λ₯Ό μμ±νλ μμ΄λ€.
* κ°λ°μμ μ€μλ‘ μ€ν λ°μ±μ΄ μΌμ΄λλ©΄,
* μμ μλμ μ°¨μ΄ κ°μ΄ 10λ°°μ μλκ° μ°¨μ΄λκ² λλ€.
*/
before = System.currentTimeMillis();
long sum2 = 0;
for (int i = 0; i < Integer.MAX_VALUE; i++) {
sum2 += i;
}
System.out.println("non-autoboxing : " + (System.currentTimeMillis() - before));
}
}