Welcome to the Java Programming Forums


The professional, friendly Java community. 21,500 members and growing!


The Java Programming Forums are a community of Java programmers from all around the World. Our members have a wide range of skills and they all have one thing in common: A passion to learn and code Java. We invite beginner Java programmers right through to Java professionals to post here and share your knowledge. Become a part of the community, help others, expand your knowledge of Java and enjoy talking with like minded people. Registration is quick and best of all free. We look forward to meeting you.


>> REGISTER NOW TO START POSTING


Members have full access to the forums. Advertisements are removed for registered users.

Results 1 to 4 of 4

Thread: what's the output?

  1. #1
    Junior Member
    Join Date
    Nov 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default what's the output?

    Hi all, I was wondering what the output to this tokenizer problem would be?
    int n = 0;
     for (StringTokenizer st = new StringTokenizer("1,'2,3',4", ","); st.hasMoreTokens(); n++) 
     {
         String s = st.nextToken();
     }
     System.out.println(n);
    is the output 1? Any help is appreciated!

    Thanks,
    dc
    Last edited by helloworld922; November 27th, 2010 at 10:04 AM.


  2. #2
    Super Moderator helloworld922's Avatar
    Join Date
    Jun 2009
    Posts
    2,896
    Thanks
    23
    Thanked 619 Times in 561 Posts
    Blog Entries
    18

    Default Re: what's the output?

    If you're unsure of the output, you can type it in and try it out (this is the the best way to see for sure what the code will do).

  3. #3
    Junior Member
    Join Date
    Nov 2010
    Posts
    12
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Default Re: what's the output?

    Unfortunately I don't know how to test the code.... I've just started using netbeans

  4. #4
    Administrator copeg's Avatar
    Join Date
    Oct 2009
    Location
    US
    Posts
    5,320
    Thanks
    181
    Thanked 833 Times in 772 Posts
    Blog Entries
    5

    Default Re: what's the output?

    See Trail: Getting Started

Similar Threads

  1. Why am I getting this output?
    By ptabatt in forum What's Wrong With My Code?
    Replies: 5
    Last Post: August 6th, 2010, 07:36 PM
  2. need help with output.
    By VictorCampudoni in forum What's Wrong With My Code?
    Replies: 0
    Last Post: June 24th, 2010, 11:25 PM
  3. xml output problem
    By tsili in forum Java Theory & Questions
    Replies: 4
    Last Post: May 25th, 2010, 04:56 AM
  4. el gato as output
    By bgwilf in forum What's Wrong With My Code?
    Replies: 1
    Last Post: May 18th, 2010, 07:02 AM
  5. OutPut.
    By chronoz13 in forum Java Theory & Questions
    Replies: 3
    Last Post: August 29th, 2009, 10:54 AM