I. Automatic conversion of data types
public class test{public static void Main (string[] args) { int a = 1; Double b = 1.5; Double A_b_count = a+b; When integral and double are added, the result is automatically converted to double type String c = "Ling"; Char d = ' Morning '; Char e = ' good '; String c_d_e_content = c+d+e; When the character type is added to the string type, the result is automatically converted to the string type System.out.println (a_b_count); System.out.println (c_d_e_content); }}
Ii. Coercion of data types
public class test{public static void Main (string[] args) { int a = (int) 10.2; Casts the double type data to reshape double b = (double) ten; Casts the data of an integral type to a double type System.out.println (a); System.out.println (b); }}
An int and a double can be forced to convert each other.
Char and string types cannot be forced to convert to and from each other.
Automatic conversion of Java data types, with casts