Data Types in JVM
Let’s know about data types used in JVM. It is quite similar to the data types we used in Java language. There are mainly two types of data types.
- Primitive Data Type.
2. Reference Data Type.
Primitive Data Type
It is the same thing when it is compared to Java language, primitive data type is holding the value itself.
There is a little difference when it comes to boolean. When boolean in JVM, it is represented by INT or BYTE. Boolean false is 0, and true is non-zero. If it is an array, it represented by an array of bytes.
Size of primitive data types also same as in the Java language.
Sizes of primitive data types are byte (8 bits), short (16 bits), int (32 bits), long (64 bits), float (32 bits), double (64 bits), and char (16 bits).
There is a new primitive data type called Return Address data type that is used to implement the final block/keyword. It is specific to the JVM.
Reference Data Type
It is the same thing when it is compared to Java language, primitive data type is not holding the value itself but a reference.
There are three types of references can hold,
- Class Reference: Hold the reference of an instance of the class.
- Interface Reference: Hold the reference of an instance of the class which is implemented the particular interface. As an example, let’s say interface A is implemented by class B, interface reference holds the reference of an instance of class B.
- Array Reference: Hold the reference to an array.
There is something called Null Reference, which is reference to no-where.