Automatic boxing and unboxing

1. Automatic packing

  Integer i = 123;

2. Automatic unpacking

  int i = new Integer(123);

3. Pay attention

  Numbers between Integer objects [-128, 127] are still treated as primitive data types, for example

  Integer i1 = 100;

  Integer i2 = 100;

  System.out.println(i1 == 12); //The result is true at this time

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325167096&siteId=291194637