Basic Knowledge of Java Data Types
Java has a total of eight primitive data types, which will be gradually introduced in this section:
byte
: 8 bits, maximum storage value is 255, data range is between -128 and 127.short
: 16 bits, maximum storage value is 65536, data range is between -32768 and 32767.int
: 32 bits, maximum storage value is 2^32 - 1, data range is between -2^31 to 2^31 - 1.long
: 64 bits, maximum storage value is 2^64 - 1, data range is between -2^63 to 2^63 - 1.float
: 32 bits, data range is between 3.4e-45 to 1.4e38. When assigning directly, a suffix 'f' or 'F' must be added after the number.double
: 64 bits, data range is between 4.9e-324 to 1.8e308. When assigning, you can optionally add a suffix 'd' or 'D'.boolean
: Only two possible values, true and false.char
: 16 bits, stores Unicode characters, assigned using single quotes.
However, in CoreExtensions, we will only use string, int, float, double, and boolean data types. For those of us who aren't familiar with Java, it's enough to remember how to fill in and use these data types.
Applying this to CoreExtensions, we can understand it as follows:
string
: Textual string, used for entering text information.int
: Integer, whether you input 5.4, 5.5, or 5.6, the decimal part will be truncated, leaving only the integer part. So, the value after typecasting will become 15.float
/double
: The main difference between these two is precision. For our purposes, we just need to remember that these types are for decimal numbers. If you want to set it as 15, you need to set it as 15.0. Similarly for other integers, otherwise it might cause game crashes due to incompatible data types.boolean
: Takes values true or false, representing "is" and "isn't" respectively.
Last updated