In this section, identifiers are relatively simple and there is nothing to record. Take notes on the Basic Java data types.
Java has four basic data types:
1. Logical (Boolean)
The boolean type has only two values, true and false. In Java, 0/1 cannot be used to indicate true/false, just like C/C ++!
2. Balanced type
Char type, useSingle quotesEnclosedLetter (cannot make string)Such as char c = 'n.
In the escape type, the special Escape Character "\". The most common escape characters are:
'\ N': newline' \ t': tab, where \ indicates escape, for example, \ "output is", \ outputs \.
3. Integer
There are four types: byte, short, Int, and long.
The byte type is 8 bits, the short type is 16 bits, the int type is 32 bits, and the long type is 64 bits.
4. Floating Point Type
Float is divided into two types: float and double. Float is called Single-precision, which is 32-bit, double is double, and 64-bit. Note that the default type of a decimal point (such as 1.0) is double!
Example:
Float F = 10.1 this will report an error during compilationBecause 10.1 is of the double type by default, it is not automatically converted to the float type.
If you want to assign 10.1 to the float type,The correct writing method is: Float F = 10.1f.