I don't quite understand your question, but I'll give some advice.
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...
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.