I\'m having a problem with my hangman program. I really think what I need to do is beyond what I understand about java. Here\'s my code
import java.io.BufferedRe
You need to save the read line in a String
object and assign it to a certain field of the array. For example:
wordList[0] = myString;
This would assign the value of myString
to the first field of your array.
1) What you've got so far looks pretty good :)
2) Since you don't know exactly how many or few words you'll have, you don't want an "array". You're probably better off with an "ArrayList". Arrays are "fixed". Lists are "variable".
3) For each "word" you read, just ".add()" it to your arraylist
Voila! Done.
Here's a complete example: