Autoboxing and Methods

autoboxing occurs whenever a primitive type must be converted into an object; auto-unboxing takes place whenever an object must be converted into a primitive type.

autoboxing/unboxing might occur when an argument is passed to a method, or when a value is returned by a method.

For example, consider this example:

public class Main {
  static int m(Integer v) {
    return v; // auto-unbox to int
  public static void main(String args[]) {
    Integer iOb = m(100);
  Java Book 
    Language Basics  

Autoboxing Autounboxing:
  1. Autoboxing and auto-unboxing
  2. Autoboxing and Methods
  3. Autoboxing/Unboxing in Expressions