0% found this document useful (0 votes)
12 views

Token Java

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Token Java

Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

A Java program is basically a collection of classes.

A class is defined by a set of declaration statements and methods containing


executable statements.

Most statements contain expressions which describe the actions carried out on
data.

Smallest individual units in a program are known as tokens.

In simple, a Java program is a collection of tokens, comments and white space.

Java language includes five types of tokens:

1) Reserved keywords

2) Identifiers

3) Literals

4) Operators

5) Separators

Keywords :

Keywords are an essential part of a language definition.

 Java language has reserved words as keyword.

 Keywords have specific meaning in Java we cannot use them as names


for variables, classes, methods and so … on.
 All keywords are to be written in lower case letters.

 Java is case sensitive.

Identifies :

 Identifiers are programmer designed tokens.

 They are used for naming classes, methods, variable objects, labels,
packages and interfaces in a program.

 Java identifiers follow the following rules.

1) They can have alphabets, digits & underscore & dollar sign characters.

2) They must not begin with a digit.

3) Upper case & lower case letters are distinct.

4) They can be of any length.

Literal :

Literals in Java are a sequence of character (digits, letters and other character)
that represent constant values to be stored in variables.

Integer literals

Floating point literals

Character literals

String literals

Boolean literals
Operators :

An operator is a symbol that takes one or more argyments and operates on


them to produce a result.

Separators :

Separators are symbols used to indicate where groups of code are divided and
arranged.

Parentheses ( ) : Used to enclosed parameters in method definition.

Braces { }:

1. Define a block of code for classes methods and local scope.

2. Automatically initialize values to array.

Brackets [ ] : Used to declare array types.

Semicolon (;) : Used to separate statement.

Comma (,) : Used to separate identifiers in a variable deceleration.

You might also like