Token

A token is a building block of java. It is the smallest unit of information that can be stored in java. Basically when you are writing a java program everything that u use is a token. There are many types of tokens in java. They are as follows.

  • Keywords
  • Identifiers
  • Literals/constants
  • Operators
  • Separators/punctuators

Let’s see how all these tokens are used while writing a java program.

Keywords:-

These are the words that are known to the java compiler. It means that they all have some special meaning that the java compiler already know.

There are many keywords in java. Because they all have some special meaning they can’t be used as an identifier. Some examples of keywords are void, public,  int, static.

2. Identifiers:-

Identifiers are names given to the parts of a java program. They are used to identify a class, a variable, a function or any other part of a java program.

There are some rules to use an identifier. They are as follows.

1. A keyword can’t be used as an identifier.

2. The length of the identifier can be any thing.

3 It can’t start with a digit.

4. Only _(underscore) and $ (dollar)sign can be used in an identifier.

3. Literals:-

They are constants that are used in a java program. Constant is something that’s value does not change throughout the execution of a program. There are many types of constants in java. A non numerical  literal and numeric literal, Boolean literal.

4. Operators:- 

They are the symbols that are used to perform a particular task on the operands. There are a lot of operators in java. They are as follows.

Bit wise Operators

Arithmetic operators

Logical Operators

Relational operators

Conditional operator

5.Separators/ Punctuators:- 

These are symbols used to group or sepaeate a java code. examples are ( ),{} ,[],  •,; ,:.

LEAVE A REPLY

Please enter your comment!
Please enter your name here