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
import org.junit.Test;
import java.util.*;

public class ClientTest {
	private static final int COUNT = 10000000;
	private static int[] ints;
	private static Integer[] integers;

	static {
		integers = new Integer[COUNT];
		Random rand = new Random();
		for (int i = 0; i < integers.length; i++) {
			integers[i] = rand.nextInt();
		}

		ints = new int[COUNT];
		for (int i = 0; i < ints.length; i++) {
			ints[i] = rand.nextInt();
		}
	}

	@Test
	public void primitiveToObject() {
		List<Integer> objects = new ArrayList<>(ints.length);
		for (int i = 0; i < ints.length; i++) {
			int value = ints[i] + 1;
			objects.add(value);
		}
	}

	@Test
	public void objectsToPrimitiveToObject() {
		List<Integer> result= new ArrayList<>(integers.length);
		for (int i = 0; i < integers.length; i++) {
			int value = integers[i] + 1; //Unboxing
			result.add(value);           //Boxing
		}
	}
}