Ismail qouiqa 28 Jan 2020

Data types

Java counts eight Primary types, in total, each one plays a certain role and imposes a specific memory allocation size.

Data  TypeDescriptionMemory allocation Size
a byte variable hold a byte value between -128 (-1 * 2^7) and 127 (2^7 - 1), this type is usually used with Arrays to hold a sequence of raw data that could represent a JPEG picture , a large text file, etc...8 bits
short is greater than byte by 8 bits, short variables may hold a value between -32768 ( -1 * 2^15) and 32767 (2^15 - 1).from my experience, this data type is not used on a day-to-day basis, unless you work on high-performance demanding or mathematical application.16 bits
char variables hold 16 bits that are Unicode encoded values (UTF-16). let's take the 'a' encoded character, its hexadecimal value is 0x0061 which is the equivalent of the binary 0000000001100001 value, luckily, we don't have to deal with bits to refer to characters. In the real world, char data types are rarely used, we use instead String objects.
16 bits
This type is regularly and widely used in the world of java for holding integer values. An int variable may hold a value between -2147483648 ( -1 * 2^31) and 2147483647 (2^31 - 1).32 bits
long is greater than int by double, which means, it may hold a value between -9223372036854775808 ( -1 * 2^63) and 9223372036854775807 ( 2^63 - 1), as with short type, it isn't a type that we'll use regularly.64 bits

float type is used for manipulating floating-point values, its boundaries are greater than integer even though they got the same allocation size,

(1.40129846432481707e-45, 3.40282346638528860e+38). explaining this in details is beyond the scope of this section but briefly, it is is due to the IEEE 754 standard that imposes a specific binary composition on float values that causes them to become less precise but could be greater than what a maximum integer value can be.  

32 bits
double is greater than float by double, as with long and short data types, this data type is specifically used in the mathematical or scientific context 64 bits
boolean type is used to hold true or false booleans values, boolean variables are usually used to represent objects state.JVM-dependent (on hotspot jvm, i got approximately one byte=8 bits)

So far, we've seen only primary data types.
Another data type exists and especially for objects, it is called Reference data type. we call it this way, because when we allocate a fragment of memory during instantiation, we get a reference pointing to it that allows us to access that fragment.
For the following ClassA on line 3
We have the variable declaration below on line 7  whose type is of ClassA