View Single Post
  #3 (permalink)  
Old 08-07-2007, 06:50 AM
coco coco is offline
Member
 
Join Date: Jul 2007
Posts: 39
coco is on a distinguished road
I don't quite understand your question, but I'll give some advice.

Code:
String word = hello; for(int i = 0; i < word.length; i++) { word.replace(word[i], "*"); }
If my code above is syntactically correct, that will replace all letters in "word" with *. But since you've changed "hello" to "*****" you've lost the secret word completely. Maybe you want something like...

Code:
String word = hello; String coverUpWord = ''; for(int i = 0; i < word.length; i++) { coverUpWord += '*'; }
Now both the above use for-loops not while-loops, but they are essentially the same. Why is it that you can't use a while-loop?

Greetings.
Reply With Quote