What is the difference between a long integer variable and a short integer variable? Please give an example.
The memory sizes allocated by them are different, so they have different value ranges. The length of short int is 2 bytes, so it can be expressed in the range of 1 5th power minus1to minus 215th power. If an integer exceeds the power of 2 15, 32768 will overflow and become a complex number. The length of int is 4 bytes, so when the value exceeds the power of 3 1 minus 1 of 2, it will overflow, that is, 21500,000, and its expression range is wider than short. Long int is 8 bytes long, so it can be expressed as 2 to the 63rd power minus 1, that is, 9.22 times 10 to the 8th power. Of course, the premise is that you don't use Windows. There is no difference between long integer and integer in Windows, which are all 4 bytes, and other platforms such as Linux or Mac are all 8 bytes, which is different from Java.