Literals in Java
Literals are data that are used for representing constant values.
Java literals are categorized into five types.
-
Integer Literals: Whole numbers without precision (decimal points) are called "integer literals."
Example:
- Floating Point Literals:Numbers with precision (decimal points) are referred to as "floating-point literals."
Example:
- Character Literals:A character enclosed in single quotes is referred to as a "character literal." Character literals are used to represent individual characters.
Example:
- String Literals:A group of characters enclosed in double quotes is indeed called a "string literal."
Example:
- Boolean Literals:A boolean literal is a representation of a boolean value, which can be either true or false.
Example:
boolean a=true;
boolean a=false;