The role of + in the output sentence in JAVA

The + sign in the output statement of System.out.println() is handled differently according to the data types of the two sides. There are two cases.
① Output string after +, for example, 1+"a" output is 1a
②After + output number, not string, such as 1+'a', output is 98
people understand, think 1+"a", String The priority of the class is relatively high, so the 1 is converted into a string, and finally connected, 1+'a' is an Int type with higher precision, so convert a to an int type and add

Guess you like

Origin blog.csdn.net/zzc15768234368/article/details/108915445