如何修复以下代码的 arrayOutOfBoundException 错误消息。这对我来说似乎在逻辑上是正确的。但我不确定为什么会收到此错误。在这方面需要帮助
public class list {
public String reverseStr(String input){
String reverString = input;
int j=0;
Character rev[] = new Character[reverString.length()-1];
for(int i= reverString.length()-1;i> 0; --i){
for(j = 0;j<= reverString.length()-1; ++j){
rev[j] = reverString.charAt(i);
}
}
String output = String.valueOf(rev[j]);
return output;
}
public static void main(String args[]){
String reverse = "Ambika";
list li = new list();
System.out.println("The reverse of " + reverse + " is " + li.reverseStr(reverse));
}
}