Can different types of data in Java be operated? For example, can single precision and int types be added directly?
in JAVA, basic types (except boolean) can be automatically converted, and the conversion forms are: byte,short,char-int-long-float-double. This is the order of automatic conversion, in which byte, short and char are automatically converted into int during operation, while int and long are automatically converted into long during operation. From the above, it can be seen that float and double are automatically converted into double and then calculated, while int and float are converted into float and then calculated. In other words, a small expression range can be automatically converted into a large expression range (the expression range does not refer to the size of the type). Secondly, if you want to get a certain type of numerical value, you can also achieve it through forced conversion.