The smallest individual and logical unit of the java statements are called tokens. In Java there are five types of tokens used. These tokens are - 1. Reserved keywords, 2. Identifiers, 3. Literals, 4. Operators, 5. Separators
Java Tokens
The
smallest individual and logical unit of the java statements are called tokens.
In Java there are five types of tokens used. These tokens are -
1.
Reserved keywords
2. Identifiers
3. Literals
4. Operators
5. Separators
Keywords
are the reserved words which are enlisted as below-
2. Identifiers
Identifiers
are the kind of tokens defined by the programmer. They are used for naming the
classes, methods, objects, variables, interfaces and packages in the program.
Following are the rules to be followed for the
identifiers-
1. The
identifiers can be written using alphabets, digits, underscore and dollar sign.
2. They
should not contain any other special character within them.
3. There
should not be a space within them.
4. The
identifier must not start with a digit, it should always start with alphabet.
5. The
identifiers are case-sensitive. For example -
int a;
int A;
In above
code a and A are treated as two different identifiers.
6. The
identifiers can be of any length.
3. Literals
Literals
are the kind of variables that store the sequence of characters for
representing the constant values. Five types of literals are -
1.
Integer literal
2.
Floating point literal
3.
Boolean literal
4.
Character literal
5.
String literal
As the
name suggests the corresponding data type constants can be stored within these
literals.
4. Operators
Operators
are the symbols used in the expression for evaluating them.
5. Separators
For
dividing the group of code and arranging them systematically certain symbols
are used, which are known as separators. Following table describes various
separators.
Object Oriented Programming: Unit I: Introduction to OOP and Java : Tag: : - Java Tokens
Object Oriented Programming
CS3391 3rd Semester CSE Dept | 2021 Regulation | 3rd Semester CSE Dept 2021 Regulation