Current location - Plastic Surgery and Aesthetics Network - Plastic surgery and medical aesthetics - Literal quantity of plastic
Literal quantity of plastic
First of all, you should make it clear that byte type represents an 8-bit byte, which is used to represent some basic characters, and int is an integer with a length of 32 bits. When initializing a byte of data in Java, you can use characters or integers, but this integer must be between-128 and 127 (because byte is 8 bits), and it will convert this number into characters and store it, so your first two lines of code will be fine. There is a problem in the fourth line: A and B are byte-typed, and their addition will be automatically converted into int before addition. Of course, the result of addition is also int type, but if you want to assign the number of int type to C of byte type, you obviously need to cast it, so Java will report an error, and so will the fifth line. The sixth line is a little special Note that the compiler will automatically treat 64+ 1 as 65, which has the same effect as c=65. Since 65 is in the range of-128 and 127, the assignment can't go wrong.