Showing posts with label Literal. Show all posts
Showing posts with label Literal. Show all posts

Sunday, March 9, 2014

Literal



A literal is any number, text, or other information that directly represents a value.


Literal format of String

eg.
String s1 = "This is the literal format of String";

"This is the literal format of String" is the String literal.

This is as opposed to:

String s2 = s1;

where s2's value is a reference to another variable.


Literal format of int

eg.
int num1 = 500;

500 is the int literal.

This is as opposed to:

int num2 = num1;

where int2's value is a reference to another variable.


For a listing of literals for all Java types also see:
"Primitive Data Types (The Java™ Tutorials > Learning the Java Language > Language Basics)" ( http://bit.ly/xesQuj )