A literal is nothing but a value which is stored into a variable in the program.
int x =1520;
char c =”x”;
boolen b =false;
In the above statement the right hand side values are called literals. java support different types of literals such as:
int x =25; // The number 25 in decimal
int y =031; // The number 25 in octal
int z =0x19; // The number 25 is in hexadecimal
Floating literal represent the decimal value with a fractional component. Like 5.2,0.0004,2.15 etc .while writing the floating literals we can use E or e for scientific notation, F or f for float literal and D or d for double literal
double x =345.67;
Character literals represents the following
Character literals should be enclosed in single quotation mark.
String literals represent objects of string class. For example vivtech, lakshya, rajeshKumar, BQ1210, etc comes under string literals which can be directly stored into a string object.
Boolean literals represent only two values such as True and False that means we can store either true or false into a boolean type variables.
Silan Software is one of the India's leading provider of offline & online training for Java, Python, AI (Machine Learning, Deep Learning), Data Science, Software Development & many more emerging Technologies.
We provide Academic Training || Industrial Training || Corporate Training || Internship || Java || Python || AI using Python || Data Science etc