0

每当我运行此方法时-

stringBot = bot.getText();
        stringTop = top.getText();
        intBot = stringBot.length();
        intTop = stringTop.length();
        String stringMove = "";
        r=0+Math.random()*intTop;
        if (intBot > intTop &&intBot>1 ){
              lastBot = stringBot.charAt(intBot-1);




 //stringMove =stringTop.substring(0,(int) r) + lastBot + stringTop.substring(intTop+1);



              top.setText(stringTop);
              stringBot=stringBot.substring(0,intBot-1);

              bot.setText(stringBot);
        }
        else if (intTop >= intBot &&intTop>1 ){
              lastTop = stringTop.charAt(intTop-1);
              stringMove = stringMove+lastTop;
              top.setText(stringBot+stringMove);
              stringTop=stringTop.substring(0,intTop-1);

              top.setText(stringTop);
        }

我在评论部分收到错误,请帮助我。该错误并不完全是语法错误,因为当我编译时它不会识别错误,直到我单击左按钮时实际运行该方法。然后它给了我一个终端窗口

4

1 回答 1

0

你有stringTop.substring(intTop+1)哪里intTop = stringTop.length();
所以你应该有例外,因为intTop+1> 的长度stringTop

于 2013-03-08T04:55:40.603 回答