Sitemap

Data Types in JVM

2 min readMay 15, 2021
Press enter or click to view image in full size

Data types in JVM does not same as the data types in Java. But fortunately most of them are same.

There are 2 major data types in JVM known as Primitive data type and Reference Data Type. These can be categorized in to further as shown above. Let’s discuss one by one in a more detailed manner.

1. Primitive:

The primitive types holds the values itself. The primitive type can be categorized into 3 named as Numeric, Boolean and Return Type Address.

1.1 Numeric data type holds the numerical values of of both floating and integer.

1.1.1Floating ====> Float, Double

1.1.2Integer ====> byte, int, char, short, long

1.2 Boolean data type is represented by int and byte

If it is boolean false, then represented in zero,

If it is boolean true, then represented in non-zero,

If it is operatable boolean. then represented by int value,

If it is array of boolean, then represented by array of bytes.

1.2 Return Address Type

The developers do not have access to this data type in JVM since we can not find in our

language. It provides a position of byte code which holds the jsr, jsr_w and ret instructions.

2. Reference:

The reference type does not hold the value it self but refer. There are 3 reference data type.They are

2.1 Class: Class is reference to another class instance.

2.2 Interface: Interface is reference to the implementation of particular class.

2.3 Array: Array is reference to another array.

The size of data type is same on every environment except long. Because it takes 64 bits to store long values since it does not depend on underlaying platform.

Important:

There is special word we use in JVM called “WORD”.

“WORD” can be assigned with the values for it’s length. But there are 2 rules enforced to define the the length of word size.

  1. The “WORD” should be able to hold any primitive data type.
  2. In order to hold the long or double data type values, two “WORD”s should be used.

Hope you will be able to get a clear understand about the data types used in JVM.

Stay Safe !!!

References:

https://www.youtube.com/watch?v=6AWckdRYWTI&list=PLD-mYtebG3X-rF1hU16AC3Rf9E-mAAkXJ&index=3

--

--

No responses yet