Win a copy of The Java Performance Companion this week in the Performance forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

need help in word guessing game

 
Clara Johnson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
this is a simple word guessing game that i have made, how many words can you make from the word "netbeans"
i want to store the words guessed by the user in an array that keeps on adding the words the user guesses...please help someone
this is my coding


 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Clara,
You don't say what you are stuck on.

One general tip: you want to use an ArrayList, not an array. With an ArrayList, you don't need to know the size in advance.
 
Clara Johnson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
thanks for the help, well i am stuck on how to do this with array list?? could you please give me some example...
 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
First you need to instantiate the ArrayList. This would be a local variable, like result. Then you need to add Strings to it. Where do you think you could do that in your code?
 
Clara Johnson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
should i do it in here?? inside the if-else condition...or what would you suggest?

 
Jeanne Boyarsky
author & internet detective
Marshal
Posts: 34672
367
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
No, I wouldn't do it inside the if statement (or the loop for that matter. You only want to add the word once per guess.

Which means my advice about where to create the ArrayList wasn't valid either. It needs to be created outside the check() method so you can store state across method calls to check().
 
Clara Johnson
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
is it ok?? what to do now??

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic