What is Autoboxing? : Autobox Unbox « Data Type « Java






What is Autoboxing?

 
 
import java.util.HashMap;
import java.util.Map;

public class Main {
  public static void main(String[] args) {
    Map<String, Integer> map = new HashMap<String, Integer>();

    map.put("Age", 25);

    int age = map.get("Age");

    Integer newAge = age + 10;
  }
}

   
  








Related examples in the same category

1.Type conversion (JDK1.5 Autoboxing/Unboxing)
2.Demonstrate autobox and unbox.Demonstrate autobox and unbox.
3.Autobox unbox takes place with method parameters and return values.Autobox unbox takes place with method parameters and return values.
4.Autobox unbox occurs inside expressions. Autobox unbox occurs inside expressions.
5.Autobox unbox: convertAutobox unbox: convert
6.Autobox unbox a Boolean and Character. Autobox unbox a Boolean and Character.
7.An error produced by manual unboxing. An error produced by manual unboxing.
8.Java Autobox and UnboxJava Autobox and Unbox
9.Autobox DemoAutobox Demo
10.Autoboxing/unboxing takes place with method parameters and return values.
11.Autoboxing/unboxing occurs inside expressions.
12.Auto-unboxing allows you to mix different types of numeric objects in an expression.