Friday, 25 August 2017

Java Token

What is Token?

Smallest individual units in the program are called token.

Tokens are the various Java program elements which are identified by the compiler. A token is the smallest element of a program that is meaningful to the compiler. Tokens supported in Java include keywords, variables, constants, special characters, operations etc.In other words, smallest individual units in a program are called token.

java toekn, keyword, identifier, const, constant, literal, separator,PK dabhi

1) Keyword:-

In Java, a keyword is a word with a predefined meaning in Java programming language syntax. which are reserved and each one has its unique meaning. They can't be used as an identifier.

There are  Following types of the keyword in java.

2) Identifier:-

An Identifier is a name given to a variable, a method, or a class, To declare identifier we want to follow some rules :

  • The identifier may consist of letters (Uppercase to Lowercase), digits, underscore or dollar sign.
  • It must not start with a number.
  • No whitespace is allowed.
  • No keyword can be used as an identifier.


The value that cannot be modified is called constant.
Const keyword is used to define constant.


In Java, any constant values are known as literals. 
The literal can be any one of the following :

Integer Literal :

Ex  : int x=300;
Here X is variable and 300 is a value which is integer literal.

Floating-points Literal :

Ex : double d=30.2;
Here 30.2 is floating-point literal.

Character  Literal :
Ex : char c="a";1111
Here is 'an' is a character literal.


-->The separators are used to separate the statement from each other. For example, the semicolon is used to terminate a statement. The list of various separators is shown below :

what is white-space?

The white-space can be a space, a tab, or a line. The extra white spaces are ignored by java compiler. Therefore if you write your program in a single line it makes no difference.

Like JavaXpert Facebook Page For More Update...

Post a Comment

Click Here