If I write something like this
System.out.println(19);
Which type has the ’19’? Is it int or byte? Or doesn’t it have a type yet?
This 19 is known as an integer literal. There are all sorts of literals, floating point, String, character, etc.
What is integer literal
Integer data types consist of the following primitive data types: int,long, byte, and short.byte, int, long, and short can be expressed in decimal(base
10), hexadecimal(base 16) or octal(base 8) number systems as well.
Prefix 0 is used to indicate octal and prefix 0x indicates hexadecimal when using these number systems for literals.
Examples:
int decimal = 100; int octal = 0144; int hexa = 0x64;
Literal means any number,Text or Other information that represents a value.
Different Values that can be assigned to Integer Variable (Integer data type Literal) are
- Decimal Literals
- Octal Literals
- Hexadecimal Literals
- Binary Literals
- Long Literals
- Values with Underscore in Between