Results 1 to 4 of 4
  1. #1
    TheRocket is offline Member
    Join Date
    Nov 2008
    Posts
    20
    Rep Power
    0

    Default Count the characters in an input box.

    Hi Everyone,

    I am fairly new to java and have got stuck with how to count how many characters were inputted on an input box. I have it saved as a variable but am unsure what function or method to use.

    Sorry for the vague question but I hope someone will understand me, if not I will try and post some code tomorrow.

    Thanks

  2. #2
    matzahboy is offline Member
    Join Date
    Nov 2008
    Posts
    67
    Rep Power
    0

    Default

    Let's say the the input is saved as a string called theWord

    The number of characters would be equal to theWord.length()

  3. #3
    TheRocket is offline Member
    Join Date
    Nov 2008
    Posts
    20
    Rep Power
    0

    Default

    Thanks a lot for the reply, that makes total sense.

    So could I then convert the variable to an int after finding out the length or just use.

    length=variable.length()

    length being a new variable.

  4. #4
    CJSLMAN's Avatar
    CJSLMAN is offline Moderator
    Join Date
    Oct 2008
    Location
    Mexico
    Posts
    1,159
    Rep Power
    8

    Default yep...

    ... and "length" would have to be declared as an int

    Luck,
    CJSL
    Chris S.
    Difficult? This is Mission Impossible, not Mission Difficult. Difficult should be easy.

Similar Threads

  1. count character in text file as input file
    By aNNuur in forum New To Java
    Replies: 7
    Last Post: 03-25-2010, 04:01 PM
  2. Getting row count
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 02-11-2008, 08:49 AM
  3. Getting row count from executeQuery()
    By Java Tip in forum Java Tip
    Replies: 0
    Last Post: 12-05-2007, 02:31 PM
  4. How to remove Control Characters from an input file?
    By renjan in forum Advanced Java
    Replies: 0
    Last Post: 08-01-2007, 03:33 PM
  5. how to take input and verify input in Java programs
    By bilal_ali_java in forum Advanced Java
    Replies: 0
    Last Post: 07-21-2007, 08:46 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •