Data Types in Java: a different approach

As far as I think, the need of having different data types in java is execute the instructions properly to serve the request. 

JVM supports two kinds of data types: Primitive & Reference.

Primitive data type

Numeric
Floating point (float & double)
Integral (byte, short, int, long, char)

Boolean
Even though boolean is a primitive data type, its represented using byte or int.
Boolean value representations:
false: 0 (zero)
true: non-zero integer

returnAddress
This is unavailable to the java developer. Used to implement finally in programs. Not directly associated with the Java programming.

Reference data type
The reference type holds the reference of dynamically created objects which are in the heap.

The reference type can hold three kinds of values.

class type
Points to an object/class instance

interface type
Points to an object, which is implementing corresponding interface

array type
Points to an array instance

or “null” (Hmm.. this is the fourth one)

Difference between primitive & reference data types
The primitive data types hold the value itself. But reference data types hold reference to objects. Means they are not objects, but reference to objects.

What is a word?
Word is again an abstract concept, which is the basic unit of size for data values in JVM. What the specification demands is, the data types byte, int, short, char, float, returnAddress & reference should fit in to a WORD! Means, 32 bits at least. Afaik, the motive behind the abstract concept of word is that, the amount of memory assigned to a program shouldn’t be a limiting factor for its execution.

Advertisements