Java Basic data types and package types detail the differences between of int and Integer
- 2020-06-07 04:34:21
int is one of the eight raw data types provided by java.
Java provides wrapper classes for each primitive type, and Integer is the wrapper class java provides for int (that is, Integer is an java object, whereas int is just a primitive data type). int defaults to 0, while Integer defaults to null, meaning that Integer can tell the difference between an unassigned value and a value of 0, while int cannot express an unassigned value. For example, to express the difference between not taking the test and a score of 0, only Integer can be used. In JSP development, Integer is default to null, so el expression will be blank string when displayed in the text box, while int default is 0, so el expression will be 0 when displayed in the text box, so int is not suitable as the type of form data in the web layer.
In Hibernate, if OID is defined as Integer type, THEN Hibernate can determine whether an object is temporary based on whether its value is null, and if OID is defined as int type, its ES36en-ES37en attribute needs to be set to 0 in the hbm mapping file.
In addition, Integer provides several operations related to integers, such as converting a string to an integer, and constants representing the maximum and minimum values of integers are defined in Integer.
int is the basic type.
Integer is a reference type.
int a= 5;
Integer b = 5
For a you can only do calculations. Such as addition, subtraction, multiplication and division.
b you can use it for a lot of things, because it's an object, it has a lot of methods, and you can use it just like you would use an String object. java. lang. Integer is a class. Operations on it are performed through the methods of the class
int is one of the basic data types in JAVA's default 8. It is not an object of the class.
int is the basic data type, and Integer is a class that encapsulates int.
Variables declared int need not be instantiated, variables declared Interger need to be instantiated (because classes need to be instantiated)
int is the base type, and Integer is the wrapper class, which is the class.
Integer is a more advanced data type than int. Why is int used in java instead of Integer as in vb
int is the low-level machine-oriented numeric type, the data type of Primitive, and Integer is the Warpper class of int, the object-oriented object type of OOP. int 1 is generally only used for numerical calculations, while Integer is used for other objects of Java, such as Key and Value of Map, List and Element of ES1010en. int should be wrapped as Integer objects to hold numerical information.
Java provides two different types: reference types and primitive types (or built-in types). Int is the raw data type of java, and Integer is the wrapper class that java provides for int. Java provides wrapper classes for each primitive type.
Primitive types encapsulate classes
Reference types behave differently from primitive types, and they have different semantics. Reference types and primitive types have different characteristics and USES, including size and speed issues, what type of data structure the type is stored in, and the default values specified when the reference type and primitive type are used as instance data for a class. The default value for object reference instance variables is null, whereas the default value for primitive type instance variables is dependent on their type.
int 1 is generally sufficient as a numerical parameter
integer 1 is used for type conversion