+ 1

What are literals?

24th Jul 2016, 11:19 AM
Abhishek Nag
2 Answers
+ 1
A literal is a value that can be written directly into a Java program. The compiler can calculate the value it represents because most primitive data types have their own literal pattern. Literal we mean any number, text, or information  that represents a value. For instance; int month  = 10; In the above statement the literal is an integer value i.e 10. The literal is 10 because it directly represents the integer value.
24th Jul 2016, 4:44 PM
tshoswane
tshoswane - avatar
0
literal is constant int a=6; here 6 is constant(literal)
6th Aug 2016, 4:19 PM
sachin tomar
sachin tomar - avatar