Literals in Java

Literals are the value stored or given to the variable.

There are different types of Literals In Java:-

Byte Literals: – The bytes data is called as byte literals. It is the whole numbers within range  – 127 to + 127

Short Literals: – It contains the whole numbers within range – 32768 to 32767

Integer ( Int ) Literal:- It contains the whole numbers within range – 232  to 232 -1

Long Literals:- It contains the whole numbers within range – 264 to 264 – 1.The long literals must contain suffix L.

Float Literals:- It contains the fractional numbers in while the data must contain suffix F.

Double Literals:- It contains the fractional numbers.

Character (Char) Literals:- It contains the single symbol within in the single quote (‘ ‘ ). It follows the unique code and contains a total of 65536 characters.

Boolean Literals:- It is used to represent the true/false value.

String Literals:- It contains the data written within a double quote.

 

 

Leave a Reply