by Dinesh Thakur

Java Tokens:- A java Program is made up of Classes and Methods and in the Methods are the Container of the various Statements And a Statement is made up of Variables, Constants, operators etc . 

 

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.

 

Token in Java

 

When you compile a program, the compiler scans the text in your source code and extracts individual tokens. While tokenizing the source file, the compiler recognizes and subsequently removes whitespaces (spaces, tabs, newline and form feeds) and the text enclosed within comments. Now let us consider a program

 

//Print Hello

Public class Hello

{

Public static void main(String args[])

{

System.out.println(“Hello Java”);

}

}

 

The source code contains tokens such as public, class, Hello, {, public, static, void, main, (, String, [], args, {, System, out, println, (, "Hello Java", }, }. The resulting tokens· are compiled into Java bytecodes that is capable of being run from within an interpreted java environment. Token are useful for compiler to detect errors. When tokens are not arranged in a particular sequence, the compiler generates an error message.

 

Tokens are the smallest unit of Program There is Five Types of Tokens

 

 1)    Reserve Word or Keywords
2)    Identifier

3)    Literals
4)    Operators
5)    Separators







About Us

Dinesh ThakurDinesh Thakur is a Columinist and designer with strong passion and founder of Computer Notes. if you have any ideas or any request Find Dinesh Thakur on
linkedin FaceBook Twitter Google Plus