Java Tokens

0
139

In this topic, you will learn about, Java Tokens.

The smallest individual units of a program are called tokens. Java language includes five types of tokens.

  • Reserve Keyword
  • Identifiers
  •  Literals
  • Operators
  • Separators

Keywords: Keywords are reserved words that have a pre-defined meaning. They are written in lower case letters. There are 60 keywords in JAVA.

Identifier: Identifiers are used to name a variable, constant, function, class, and array. It usually defined by the user.

Rules of naming identifier:

  1. It must start with an alphabet, underscore, and dollar sign.
  2. It must not be a keyword(keywords are always written in lower case).
  3. It cannot start with digits but may contain digits.
  4. It must not contain space or any other special symbol other than the dollar.
  5. Upper case and lowercase letters are distinct.
  6. They can be of any length.

Literals: In programming literal is a notation that represents a fixed value (constant) in the source code. It can be categorized as an integer literal, string literal, Boolean literal, etc. It is defined by the programmer. Once it has been defined cannot be changed. Java provides five types of literals are as follows:

Integer-
1. Decimal-1,222
2. Octal-O12,o100
3. Hexadecimal- OX122,ox123
❖ Floating Point- 1.3 ,222.22, 9.3 etc
❖ Character- ‘1’, ‘w’
❖ String “wwf”, “123”, “!@#”
❖ Boolean – true, false

Operators: In programming, operators are the special symbol that tells the compiler to perform a special operation. Java provides different types of operators that can be classified according to the functionality they provide. There are eight types of operators in Java, are as follows:

  • Arithmetic Operators
  • Relational Operators
  • Logical Operators
  • Assignment Operators
  • Increment and Decrement Operators
  • Bitwise Operators
  • Special Operators

Separators: The separators in Java are also known as punctuators. It indicates where codes are divided or grouped. e.g ; , . ( ) { } [ ]

LEAVE A REPLY

Please enter your comment!
Please enter your name here