What is the difference between int and Integer

The Java language provides two different types, reference types and primitive types (or built-in types) . int is a primitive data type of Java language, and Integer is a wrapper class provided by Java language for int. Java provides wrapper classes for each primitive type.

Extension:
Java's eight basic data types - wrapper classes:
byte-Byte, int-Integer, char-Character, long-Long, float-Float, double-Double, boolean-Boolean, short-Short
package types and primitive types have many Difference: primitive data types are passed by value when passing parameters, while encapsulated types are passed by reference. Object reference instance variables default to null, while primitive type instance variables default to their type (int-0, short-0, long-0L, byte-0, float-0.0F, double-0.0, char-u0000, boolean-false)

Why are there basic types in java and why are there wrapper types?
https://blog.csdn.net/min996358312/article/details/62894674

Guess you like

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