According to the docs on Integer
class:
The Integer class wraps a value of the primitive type int in an object. An object of type Integer contains a single field whose type is int.
and the docs on int
:
By default, the int data type is a 32-bit signed two's complement integer, which has a minimum value of
-2^31
and a maximum value of2^31-1
.
also, according to this Answer:
In Java, every variable has a type declared in the source code. There are two kinds of types: reference types and primitive types. Reference types are references to objects. Primitive types directly contain values.
So, my question is : How is the int
primitive type implemented in Java? Integer
being a class can imagine creating its object. However again Integer
class uses int
. In what way is int
implemented to java so that we are allowed to use it and allowed to perform all its arithmetic operations. An insight onto this would be much helpful.
I tried many existing answers and articles, however did not find an answer to my question, that include:
- Primitive Data types
- Class Integer
- Java: Primitive Data types
- Can an int be null in Java?
- Primitive data type
PS:
If any part of my question is unclear/incorrect, kindly let me know in the comments section.