First of all, the integer type defaults to int. There is no doubt about this. Secondly, within the allowed type range, here byte: -128~127 And the integer int 1 is in this range, the compiler will automatically perform downward conversion of the constant. If the constant exceeds this range, the compiler will directly report an error.
Wrong, two integers are added together. If it is less than or equal to int, the default is int. If one of them is long, the default is long;
You try to declare two byte variables, and then add them and assign them to another byte variable. The compiler will prompt an error and forced type conversion is required
First of all, the integer type defaults to int. There is no doubt about this.
Secondly, within the allowed type range, here byte: -128~127
And the integer int 1 is in this range, the compiler will automatically perform downward conversion of the constant.
If the constant exceeds this range, the compiler will directly report an error.
Byte, short, char, and boolean are all processed as int at the bottom layer
Wrong, two integers are added together. If it is less than or equal to int, the default is int. If one of them is long, the default is long;
You try to declare two byte variables, and then add them and assign them to another byte variable. The compiler will prompt an error and forced type conversion is required
Check this article: http://www.programgo.com/arti...
Divided into automatic conversion and forced conversion