Question: According to the [Java Tutorial](https://docs.oracle.com/javase/tutorial/java/data/autoboxing.html), the

> 
> Converting an object of a wrapper type (Integer) to its corresponding primitive (int) value is called unboxing. The Java compiler applies unboxing when an object of a wrapper class is:
> 
> 
> * **Passed as a parameter to a method that expects a value of the corresponding primitive type.**
> * **Assigned to a variable of the corresponding primitive type.**
> 
> 
> 

Why does unboxing occur in this case?

```
char l = 0;
int arr[] = new int[]{1,2,3};
System.out.println(arr[new Integer(1)]);

```

Where in this scenario does either of those things happen? Is there an underlying method that governs element access in an array? Or does [] imply some sort of variable?

Answer: 
The [JLS 15, §15.10.3](https://docs.oracle.com/javase/specs/jls/se15/html/jls-15.html#jls-15.10.3) is pretty clear on this one:

> 
> ...
> 
> 
> The index expression undergoes unary numeric promotion ([§5.6](https://docs.oracle.com/javase/specs/jls/se15/html/jls-5.html#jls-5.6)). The promoted type must be `int`, or a compile-time error occurs.
> 
> 
> ...
> 
> 
> 

Similar paragraphs can be found in older JLSes, e.g. [JLS 8, §15.10.3](https://docs.oracle.com/javase/specs/jls/se8/html/jls-15.html#jls-15.10.3).
In `(arr[new Integer(1)]` the wrapper Integer gets converted to primitive type, because it is used as an array index.