kirran

Monday, May 21, 2012

About TOKENS

what is a token?

A token is nothing but smallest part of the program or individual part of the statement

Without tokens ,statement is not possible.

Tokens are of 6 types

  1. Identifiers
  2. Literals
  3. Comment symbols
  4. Separator
  5. Operator
  6. keyword

Identifier

Identifier is nothing but to identify the corresponding member, without identifier we cannot able to callback, corresponding member.

Java supported 5 types of 



  1. Package name
  2. Object name
  3. Class name
  4. Function name
  5. Variable name

Literal

Literal is a value which is possible to modify ,where as constant  also one type of literal, which does not support modifications.






5 types of literals
  1. Integer literal        Ex:  10
  2. Float literal            Ex:  10.55
  3. Boolean literal       Ex : True/False
  4. Character literal    Ex : 'a'
  5. String literal           Ex : "kirran"       .

       Comment symbols:  Java has 3 types of comment symbols
    1. Single line  -------------- C  /* and */               
    2. Multiple lines  --------------C++  is  //
    3.           Multiline/paragraph   for C,C++, Java is  /* and */
    4.  HTML comment                      /**……………*/

     Keywords

    A keyword is a word ,whose meaning is already being explained to compiler.

    Keywords are reserved words , do not use them as word.




    abstract         continue       for       new               switch


    assert***       default          goto*     package     synchronized


    boolean             do                 if          private          this


    break             double       implements     protected     throw


    byte     else     import          public          throws


    case              enum****      instanceof     return     transient


    catch           extends             int                   short       try


    char               final            interface             static     void


    class           finally            long                strictfp**      volatile


    const*        float            native           super                while

    *               not used
    **             added in 1.2
    ***           added in 1.4
    ****         added in 5.0


    Operators

     An operator performs a particular operation on the operands it is applied on


    Types of operators


    ------Simple Assignment Operator

    =       Simple assignment operator

    ------Arithmetic Operators

    +       Additive operator (also used
            for String concatenation)
    -       Subtraction operator
    *       Multiplication operator
    /       Division operator
    %       Remainder operator

    -------Unary Operators

    +       Unary plus operator; indicates
            positive value (numbers are
            positive without this, however)
    -       Unary minus operator; negates
            an expression
    ++      Increment operator; increments
            a value by 1
    --      Decrement operator; decrements
            a value by 1
    !       Logical complement operator;
            inverts the value of a boolean

    --------Equality and Relational Operators

    ==      Equal to
    !=      Not equal to
    >       Greater than
    >=      Greater than or equal to
    <       Less than
    <=      Less than or equal to

    -------Conditional Operators

    &&      Conditional-AND
    ||      Conditional-OR
    ?:      Ternary (shorthand for
            if-then-else statement)

    --------Type Comparison Operator

    instanceof      Compares an object to
                    a specified type

    ----------Bitwise and Bit Shift Operators

    ~       Unary bitwise complement
    <<      Signed left shift
    >>      Signed right shift
    >>>     Unsigned right shift
    &       Bitwise AND
    ^       Bitwise exclusive OR
    |       Bitwise inclusive OR



    Statements

    A Java statement is the smallest unit that is a complete instruction. 


    Statements must end with a semi-colon. 


    Statements generally contain expressions (expressions have a value) 


    One of the simplest is the Assignment Statement 


    <variable> = <expression>;


    For Example:
    int height; height = 34; 


















     

                                                                                                                                                                                                 

No comments:

Post a Comment