Literals
Literals are constants that do not change and may be assigned to variables.
There are seven types that can be used in java:
- Integer literals
- Floating literal
- Boolean literal
- Character literal
- String literal
- Null literal
- Class literal
Integer Literal:
Integer-literal are used to represent whole numbers. It may be a positive or a negative number without a point or comma(,).
Integer are three types that can be represented in Java:
- Decimal(base 10)
- Octal(base 8)
- Hexadecimal(base 16)
Floating Literals:
Floating literals are used to represented fractional numbers i.e. number with a point.
In exponential format a real number is divided into two parts: mantissa and exponent.
The mantissa represents the integer part and exponent represents 10 to the power of a number.
Boolean Literals
Boolean literals are used as an indicator to represent a success or failure i.e. true or false.
Character Literals:
Character literal are always enclosed within single quotes. These characters can directly be printed on an output device ( like terminal window ).
String Literal:
A group of characters enclosed within double quotes can be considered to be String literal.
Null Literal:
The null represents nothing.
Class Literal:
A class literal is an expression consisting of the name of a class, interface, or primitive type followed by a dot('.')
THANKS FOR VISIT MY BLOG...
0 comments:
Post a Comment