Page 154 - Computer science 868 Class 12
P. 154
06 VARIABLES AND
EXPRESSIONS
Learning Objectives
6.1 Keywords 6.2 Literals
6.3 Identifiers 6.4 Special Symbols
6.5 Operators
As we know, different sets of characters used in Java are letters, digits, operators, and delimiters. Each individual
character that is used for creating executable code in Java is known as a token. A token is the smallest unit that is
recognised by the Java compiler.
Every program we write is a combination of tokens. Let us take a simple example.
In the above program, every word or character separated by a space is denoted as a token. For example,
• class tokens_in_java – has two tokens;
• public static void main() – has six tokens as each opening and closing brackets are tokens separately;
• String name = "Partha Saha"; – has eight tokens.
Similarly, all programs in Java are made up of different types of tokens.
Definition
Tokens are the smallest individual part of a Java program that has a meaning to the compiler and executes the
program efficiently.
The five different types of tokens in Java are as follows:
• Keywords
• Literals
152152 Touchpad Computer Science-XII

