Java Tokens

In this tutorial you will learn about the Java Tokens and its application with practical example.

Java Tokens

The token is basically the smallest element that can be identified by the compiler. Java expressions and statements are constructed using java tokens. A java program is basically made up of different types of tokens that can either be a keyword, an identifier, a constant, a string literal, or a symbol.

Table Of Contents

Here are some types of tokens mentioned below please take a look:

  • Keywords
  • Identifiers
  • Constants
  • Separators
  • Operators

Keywords:- In Java, there are is a set of reserved words that you cannot use as an identifier. These words are known as “reserved words” or “Keywords”. Keywords are standard identifiers and their functions are predefined by the compiler. We cannot use keywords as variable names, class names, or method names, or as any other identifier.

Identifiers:- Identifier is basically used as variable names such as sum, total, etc.

Constants:- Constants are expressions with an immutable value.

Separators:- Separator is a token used to separate two individual tokens used in a java program. Separators are also known as punctuators. In Java, we have the brace { and }, parenthesis ( and ), and brackets [ and ], comma (,), semicolon (;), asterisk (*), colon (:), number sign #(hash) as punctuators.

Operators:- An operator is a symbol that represents a specific mathematical or non-mathematical operation.

In this tutorial we have learn about the Java Tokens and its application with practical example. I hope you will like this tutorial.