Literals are fixed values in Java ie the quantities
that can not be changed during program execution. There are several types of
literals.
Character Literal
– A single character enclosed within single quotes . eg. ‘A’, ‘*’, ‘5’ etc.
Integer Literal
- It consists of 0 to 9 digits and
optional + or – sign. Eg. 45, -56
Float Literal -
A number with fractional part suffixed by f. eg. 4.5f
Double Literal -
A number with fractional part suffixed by d or nothing. eg. 4.5, 4.5d
Boolean Literal – There are two Boolean literal :
true or false
String Literal – A sequence of characters enclosed
within double quotes. eg. “a3programming”
0 Comments