stringTokenzier....

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ahmee
    New Member
    • Mar 2010
    • 39

    #1

    stringTokenzier....

    Code:
    import java.util.*;
    class Strtok {
    
    public static void main(String [] args) {
    
            String Demo = "This is a string that we want to tokenize";
    
            StringTokenizer Tok = new StringTokenizer(Demo);
            int n=0;
    
            while (Tok.hasMoreElements())
                    System.out.println(++n +": "+Tok.nextElement());
            }
    }
    can any one tell me that in S.o.println why we use double +sign wid "n" and wot the need of int n=0
  • Dheeraj Joshi
    Recognized Expert Top Contributor
    • Jul 2009
    • 1129

    #2
    Code:
    ++n
    This increments the value of n by one.

    Here is your output. Where 1, 2 etc are value of n in every loop.
    Code:
    1: This
    2: is
    3: a
    4: string
    5: that
    6: we
    7: want
    8: to
    9: tokenize
    Regards
    Dheeraj Joshi

    Comment

    Working...