我的代码在eclipse工作,但在android studio中无法解决问题

时间:2017-06-01 02:54:41

标签: android eclipse

公共类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);


            }
   }

哪里有问题?我该如何解决?

1 个答案:

答案 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);
        }

}