TOKENS

Tokens:

  • Tokens are it is a small part of the program.
  • There are four types of tokens.
    1. Keywords
    2. Identifiers
    3. Literals
    4. Separators
1) Keywords
  • Keywords means the word having predefined meaning.
  • It is also known as compile aware words.
  • In Java totally we have 53 keywords 
    • eg. Class, Static, void, public etc.
  • Keywords always must be in lowercase
2)Identifire:
  • The name given by the programmer is called as identifire
    • eg. ClassName etc.
      • Rules for identifier :- 
        • Identifier cannot start with the numbers.
        • We cannot have space in between identifier.
        • We cannot write all special characters except "_" and "$".
3) Literals:
  • The value given by the programmer is known as literals.
  • There are four type of literals we have :
    • Number: 



    • Character:
      • Go for the character when we want to represent a single data.
        • Rules for character
          • The character should be enclosed within single Quote
          • In character we can write

    • String: 
      • We go for string when we want to represent a group of characters or collection of characters.
        • Rules for string
          • always the string should be enclosed within double quote
          • Any string we can write:
          • The length of the string can be anything.
    • Boolean:


4) Separators:
  • Separators are used to separate the Java member.
  • There are five different type of separators we have in the java: