|
|
| Literals |
Expert:joginder singh
what is Literals and where we use it. give me example's also thx..
|
| Answers |
Hi friend,
A constant value in a program is denoted by a literal. Literals represent numerical (integer or floating-point), character, boolean or string values.
Example of literals:
Integer literals: 1 2 4
Floating-point literals: .66 0.3 6.14
Character literals: '(' 'Z' 'k' '{'
Boolean literals:(predefined values) true false
String literals: "Hello" "abc" "gfh" "dfg"
Three reserved identifiers are used as predefined literals: true and false representing boolean values. null representing the null reference.
For more information,Tutorials and Examples on Literals visit to :
http://www.roseindia.net/java/language/java-literals.shtml
Thanks
|
Hi,
In programming, a value written exactly as it's meant to be interpreted. In contrast, a variable is a name that can represent different values during the execution of the program. And a constant is a name that represents the same value throughout a program. But a literal is not a name -- it is the value itself.
A literal can be a number, a character, or a string. For example, in the expression,
x = 3
x is a variable, and 3 is a literal.
Thanks.
|
| More Questions |
|
|
Post Answers
Ask Question
Facing Programming Problem?
|
|
|
|
|