Search:

Type: Posts; User: Norm

Search: Search took 0.10 seconds.

  1. Re: Getting an error! String.charAt(Unknown Source) ???

    Time to do some debugging to see what the code is doing. Try debugging your code by adding println() statements to show execution progress and how variable values are changing. For example:
    Add a: ...
  2. Re: Getting an error! String.charAt(Unknown Source) ???

    One potential problem I see is having class variables and local/method variables with the same name.
    There are a lot of variables named: word. Change the class variable to have a different name...
  3. Re: Getting an error! String.charAt(Unknown Source) ???

    What prints out when you added the println statements?
  4. Re: Getting an error! String.charAt(Unknown Source) ???

    What are the values of these as the loop executes: word.charAt(l) and userLetter

    Also print out this: word.length()
  5. Re: Getting an error! String.charAt(Unknown Source) ???

    Try debugging the code by adding some println statements that print out messages as the code executes and prints out the values of the variables that control the execution flow.

    Please edit your...
  6. Re: Getting an error! String.charAt(Unknown Source) ???

    Please explain.
  7. Re: Getting an error! String.charAt(Unknown Source) ???

    See the String class's API doc for its methods:
    Java Platform SE 7
  8. Re: Getting an error! String.charAt(Unknown Source) ???

    If word is a String object, you need to use a method (ends with ()s) to get its length. The String class does not have a length member.
  9. Re: Getting an error! String.charAt(Unknown Source) ???

    There are two different variables used in the posted code. The code should use the same one in both places.
    wordSoFar
    and
    word

    Use the length of word to control the loop. Get rid of...
  10. Re: Getting an error! String.charAt(Unknown Source) ???

    Post the new code and the full text of the error message.
  11. Re: Getting an error! String.charAt(Unknown Source) ???

    The error says that the index used in charAt() on line 172 is past the end of the String. Check that the String has a length > 0 before trying to get the first character in the String.

    One way...
Results 1 to 11 of 11