Java data types include basic data types (built-in data types) and reference data types.
The basic data types are: integer: Byte,short,int,long float: double,float boolean type: bool character type: Char
Reference data types include: classes, arrays, interfaces, enumerations
Differences between the base data type and the reference data type:
If it is a basic data type variable, the JVM allocates a stack space for the variable, and the stack space is stored in the variable's contents
If it is a variable of the reference data type, the JVM allocates a stack space to the variable pointer to the address of the pointed content, and allocates the heap space to the contents of the variable.
The following example illustrates this point,
int a=2;
int b=3;
System.out.println (A==B);
String C=new string ();
C= "123";
String D=new string ();
D= "123";
System.out.println (A==B);
System.out.println (A.equals (b));
D=c;
System.out.pringln (C==d);
Output:
True
False
True
True
Java Data types