Skip to main content Link Search Menu Expand Document (external link)

Tokens

  • Tokens are smallest unit of java program.
  • Tokens are classifed into 1) Keywords 2) Seperators 3) Identifiers 4) Literles

    1) Keywords

  • Keywords are predefine words in java.
  • It is also known as reserved words in java.
  • Java compiler will be aware of the keywords.

    How identifies keywords ?

  • All keywords are in lower case.
  • e.g. public,class,static

2) Separators

e.g.

{
    ;   ,   (   )   "  "    :   '  '
}

3) Literals

  • Literals are the types of values used in java program.
  • i) Numbers
    • integer - 10,1,100,15
    • float - 10.1,30.4,33.2
  • ii) Characters
    • ‘a’,’b’,’c’,’A’,’B’,’C’
    • ‘a’ != ‘A’
    • 97 != 65 (ASCII value)
    • ASCII value - byte code
  • iii) String
    • “Hello”
  • iv) Boolean
    • true/false

Note

  • Java is casesensitive.

4) Identifires

  • Identifire is name given by the programmer to the elements of java.
  • e.g. class name, variable name, method name