JAVA Tokens(Keywords, Identifiers, Literals, Punctuators and Operators)

JAVA tokens are the smallest individual unit in a program, JAVA tokens are Keywords, Identifiers, Literals, Punctuators and Operators.

JAVA Tokens(Keywords, Identifiers, Literals, Punctuators and Operators)

In this tutorial, we will learn about JAVA Tokens with the help of examples and if you are following our full JAVA course then you probably know that we have given a small introduction about JAVA Tokens but in this tutorial, we will go through more of these concepts.

The smallest possible unit of a JAVA program is known as Tokens.

Types of JAVA Tokens:


Keywords are reserved words that have a predefined meaning and they pass special meaning to the language compiler. There are 51 keywords(reserved words) in JAVA.

Some frequently used keywords are listed below:

abstract continue for new switch float boolean
goto import do  if private this break
double implements protected throw byte else public
throws case return catch extends int short
try char final interface  static void class
finally long super package enum  instanceof assert

If you want to have more knowledge about JAVA tokens then please refer to this Complete JAVA Keywords.


It is the name given by the user to the variable, function, class, method, or any other user-defined data types. It is basically the name given by the user for a unit of the program.

Being a Case-sensitive language , JAVA treats uppercase and lowercase distinctly therefore it is important to take care of upper case and lower case words.

There are some rules for a valid identifier which we need to follow while defining any identifier. They are:

  1. The first character of any identifier must be an alphabet(upper case or lower case) or can be an underscore.
  2. Other characters of the identifier can be alphabet, digit, dollar sign or underscore characters.
  3. It cannot be a reserved word.
  4. No two successive underscores allowed.
  5. An identifier cannot contain spaces.

Examples of some valid and invalid identifiers:

  • My_fiLE (VALID)
  • Hello26 or H26ello (VALID)
  • break, for or void (any keyword in INVALID)
  • Hello_World (VALID)
  • Hello World (INVALID)


It is also called Constants, thesen data items do not change their value during the time of program execution.

JAVA allows several types of Literals:

  • integer-constant
  • character-constant
  • floating-constant
  • string-constant
  • boolean-constant
  • defining-constant

We will discuss about Literals in more detail in upcoming tutorial, for now lets get to know about punctuators and operators.


The characters that are used to enhance the readability and give proper meaning to statements, expressions, beautify the program, etc. according to the syntax.

The following characters are used as punctuators or separators in JAVA:

 [ ] ( ) { } , ; : ... = # * " "


Java operators are set of data items that manipulate variables and trigger some action when applied on variables or objects in an expression.

There are different types of operators in JAVA:

  1. Arithmetic Operators( + , - , / ,* , % )
  2. Increment/Decrement Operators( ++ , --)
  3. Relational Operators( == , > , < , <=, >= , !=)
  4. Logical Operators ( && , || , ! )
  5. Conditional Operators ( ? :)
  6. Bitwise Operators ( & , | , ^ , ~ )
  7. Assignment Operators ( = , += , -= , /= , *= , %= , &= , ^= , |= )
  8. Shift Operators ( Left shift(<<) , Right shift(>>))

Lets stop here in this tutorial , we will move forward in the next tutorial. Till then Best of luck for your journey to learn JAVA.