Basic data types include byte, Int, Char, long, float, double, Boolean, and short.
The referenced data types include: Class, array, and interface.
The difference between the basic data type and the reference type is that the basic data type is allocated on the stack, and the reference type is allocated on the stack.
Therefore, let's analyze the difference between "=" and equals.
First, I will take two string objects
String A = "ABC ";
String B = "ABC ";
Then
If (A = B) {system. Out. println ("A = B ");}
Else
{System. Out. println ("! = B ");}
ProgramOutput! = B
Cause: the addresses of A and B are different. A = B compares the addresses of two variables.
Define two basic types
Int A = 4;
Int B = 4;
If (A = B) {system. Out. println ("A = B ");}
Else
{System. Out. println ("! = B ");}
Output: A = B
Cause: = compare the content of two variables
Conjecture: whether it is basic data type or reference type, they will first allocate a piece of memory in the stack. for basic types, this area contains the basic type of content; for the object type, this area contains a pointer to the real content, and the real content is manually allocated to the stack.