The notation of a value is called a literal. It is a constant that directly describes a numerical value or a character string, assuming that it will not be changed. Literal is an English word that means "as it is, as the original meaning of the word".
There are 6 types of literals in all.
The value enclosed in single quotes ('). It is used when the value is one character. In general, string literals are often used, and character literals are rarely used. However, use this character literal when using special symbols.
The value is enclosed in double quotes ("). The value can be one character.
Refers to a value without a decimal point. You can express 2,8,10, hexadecimal numbers.
Refers to a value with a decimal point. It can represent decimal numbers and exponents.
Refers to the value of a logical value.
True = true False = false
When referring to reference type data, it means that nothing is referenced.
In the following example, the numeric value 6 is assigned to the int type variable n, and the character string moji is assigned to the String type variable name. The substituted "6" and "moji" are "numerical literal" and "string literal", respectively. Will be.
int n = 6; String name = moji;
I understand that literals have no special meaning, they just mean "the characters as they are written".
Recommended Posts