8 Basic data Types
Data type bit byte value range
BYTE 8 1-128~127
Short 16 2-32768~32767
int 32 4-231~231-1
Long 64 8-263~263-1
Float 32 4 slightly
(Float a=3.0; C language does not error,java default to double type, need to be changed to float a=3.0f; )
Double 64 8 slightly
Char 2 '\u0000'~'\uffff '
Boolean 1 slightly true/false
Assignment: Assigns a value directly and copies the value .
Storage location: value stored in stack
= = Operation : Binary returns true
Reference type
Defined:
Reference type except for the base data type
Including:
classes in 1.API, such as String,File
2. custom classes, such as Personalaccount,creditaccount
3. Arrays , such as int[],string[]
Application:
1. use as a type of attribute
2. Use the return value type as a method
3. use as a form parameter type for a method
Assignment Value :
use new, String to assign a value, Copy the address .
Storage location:
A reference is stored in the stack, and the property value of the specific object is stored in the heap.
= = Operation :
True if the virtual address is the same
Data type conversions
Low -> High (target type > Source Type)
Byte -> short does not error, automatic conversion;
High -> Low
Short ->byte error, forced conversion required :(byte) short -> Byte
A summary of the Java language data types