公共类DemoWeBBrower { public static void main(String args []){
String answer = "A. hold - read";
String answerQuestion = "";
String[] arrStr1 = answer.split("\\.");
String str1 = arrStr1[1];
String[] Str2 = str1.split("-");
answerQuestion = "Jeff _____ a book right now, he _____ a story to Linda.";
for (int i = 1 ; i < Str2.length +1 ; i++){
answerQuestion = answerQuestion.replaceFirst("_____",Str2[(i-1)]);
}
System.out.println( answerQuestion);
}
}
哪里有问题?我该如何解决?
答案 0 :(得分:0)
试试这段代码
String answer = "A. hold - read";
String answerQuestion = "";
String[] arrStr1 = answer.split("\\.");
String str1 = arrStr1[1];
String[] Str2 = str1.split("-");
answerQuestion = "Jeff _____ a book right now, he _____ a story to
Linda.";
for (int i = 0; i < Str2.length(); i++){
answerQuestion = answerQuestion.replaceFirst("_____",Str2[i]);
}
System.out.println( answerQuestion);
}
}