Java Basic Tutorial
Java Advance Tutorial
In Java, literals are fixed values assigned to variables. They represent the actual data used in the code. Java supports different types of literals based on the data types.
Literal Type |
Description |
Example |
---|---|---|
Integer Literals |
Represents whole numbers (decimal, binary, octal, or hexadecimal). |
|
Floating-Point Literals |
Represents numbers with decimal points. |
|
Character Literals |
Represents single characters enclosed in single quotes. |
|
String Literals |
Represents a sequence of characters enclosed in double quotes. |
|
Boolean Literals |
Represents logical values |
|
Try it yourself