Identifiers Literals And Keywords In Java
TOKENS IN JAVA:
Literals in Java are a sequence of characters (digits, letters and other characters) that characterize constant values to be stored in variables. Java language specifies five major types of literals are as follows :
Identifiers are programmer-created tokens. They are used for naming classes, methods, variables, objects, labels, packages and interfaces in a program. Java identifiers follow the following rules:
- They can have alphabets, digits, and the underscore and dollar sign characters.
- They must not start with a digit.
- Uppercase and lowercase letters are individual.
- They can be of any length.
Identifier must be meaningful, easily understandable and descriptive.
For example : Private and local variables like “length”. Name of public methods and instance variables begin with lowercase letter like “addition”
Keywords are important part of Java. Java language has reserved 50 words as keywords. Keywords have specific meaning in Java. We cannot use them as variable, classes and method. Following table shows keywords.
abstract |
char |
catch |
boolean |
default |
finally |
do |
implements |
if |
long |
throw |
private |
package |
static |
break |
double |
this |
volatile |
import |
protected |
class |
throws |
byte |
else |
float |
final |
public |
transient |
native |
instanceof |
case |
extends |
int |
null |
const |
new |
return |
try |
for |
switch |
interface |
void |
while |
synchronized |
short |
continue |
goto |
super |
assert |
const |
|
|