Java Literals


A literal is a source code representation of a fixed value. They are represented directly in the code without any computation.

Literals can be assigned to any primitive type variable.
For example:
byte a = 100; ----- char b= ‘B’;
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.
For example:
 int decimal = 100; ------ int octal = 0144; --------- int hexa = 0x64;
String literals in Java are specified like they are in most other languages by enclosing a sequence of characters between a pair of double quotes.
Examples of string literals are:
“Helo My Name is Syed Ali Haider”;
String and char types of literals can contain any Unicode characters.
For example:
Char n=’\u0001’; ------ String n= “\u0001”;


Comments

Popular posts from this blog

Umbrella activities in Software Engineering

Operating System | Best Definition of Opetating System