Как распечатать тире «-» в той же длине, что и длина слова? Я использовал for-loop, но получил только 1 тире.для печати цикла - столько, сколько длина слова?
for(int i=0; i<secretWordLen; i++) theOutput = "-";
Главная:
public String processInput(String theInput) {
String theOutput = null;
String str1 = new String(words[currentJoke]);
int secretWordLen = str1.length();
if (state == WAITING) {
theOutput = "Connection established.. Want to play a game? 1. (yes/no)";
state = SENTKNOCKKNOCK;
} else if (state == SENTKNOCKKNOCK) {
if (theInput.equalsIgnoreCase("yes")) {
//theOutput = clues[currentJoke];
//theOutput = words[currentJoke];
for(int i=0; i<secretWordLen; i++) theOutput = "-";
state = SENTCLUE;
возможный дубликат http://stackoverflow.com/questions/7107297/what-is-the-easiest-way-to-generate-a-string-of-n -repeated-characters – holap