-
Represents data type memory range from small to large graph
-
Automatic type conversion
Assign a small value or variable to a large variable.
The following example shows that it is possible to assign a small value to a large value, but it is not possible to convert across large data types, such as: integer to integer, floating point to floating point…
Public class test {public static void main(String[] args) {public static void main(String[] args) { short b = a; System.out.println(b); Char c = a; char c = a; // Error system.out.println (c); }}Copy the code
-
Cast casting
Assign a value or variable representing a large range of data to another variable representing a small range.
Format: Data type variable name = (strong data type) value or variable
Public class test {public static void main(String[] args) {public static void main(String[] args) { short b = a; System.out.println(b); Char c = (char)a; char c = (char)a; System.out.println(c); }}Copy the code