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 2 of 2

Thread: Help! I am brand new to Java and I need help!

  1. #1
    Member
    Join Date
    Feb 2013
    Posts
    30
    Thanks
    3
    Thanked 0 Times in 0 Posts

    Default Help! I am brand new to Java and I need help!

    Hello All,

    I am taking an AP Computer Science course and I am very confused about one particular question on a quiz. Can somebody please explain why the answer is 32? Thank you so much for your time.

    Question
    Put a number in the blank so that this coding counts the number of tabs, blanks, newlines, form feeds, and other special characters in the first 10 characters of a String named s.
    for (int k = 0; k < 10 ; k++)
    if ((int) s.charAt (k) <= ________________ )
    count++;
    Answer 32


  2. #2
    Super Moderator Norm's Avatar
    Join Date
    May 2010
    Location
    Eastern Florida
    Posts
    25,042
    Thanks
    63
    Thanked 2,708 Times in 2,658 Posts

    Default Re: Help! I am brand new to Java and I need help!

    That is a poor coding technique to use 32 vs the char value that the problem talks about.
    Look at the ASCII codes table to see what values are at or below the blank character.

    The correct value for the code is ' ' (there is a blank/space between the 's
    if ( s.charAt (k) <= ' ')
    If you don't understand my answer, don't ignore it, ask a question.

Similar Threads

  1. Brand spanking new
    By Voke in forum Member Introductions
    Replies: 1
    Last Post: July 25th, 2012, 11:28 AM
  2. Brand new to Java and programming
    By mwr76 in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 26th, 2011, 08:41 PM
  3. Brand New/First Attempt
    By kevinco in forum What's Wrong With My Code?
    Replies: 3
    Last Post: August 14th, 2011, 08:45 PM
  4. Brand New
    By BigJoe in forum Member Introductions
    Replies: 1
    Last Post: December 27th, 2010, 01:26 PM
  5. [SOLVED] Brand Spanking New to Java...
    By forte in forum What's Wrong With My Code?
    Replies: 7
    Last Post: May 18th, 2010, 06:41 AM