的Android 2.3.3如何访问Android中的字符串数组位置?
这是我的代码...
String[] expression = {""}; //globally declared as empty
somewhere in the code below, I am trying to assign a string to it.
expression[0] = "Hi";
I keep getting the following error...
12-08 22:12:19.063: E/AndroidRuntime(405): java.lang.ArrayIndexOutOfBoundsException
有人可以帮助我这个.. 我们可以访问该指数为0,直接为我在做什么?
实际代码:::
static int x = 0; // global declaration
String[] assembledArray = {""}; // global declaration
assembleArray(strSubString, expression.charAt(i)); //Passing string to the method
//Method Implementation
private void assembleArray(String strSubString, char charAt) {
// TODO Auto-generated method stub
assembledArray[x] = strSubString;
assembledArray[x+1] = String.valueOf(charAt);
x = x+2;
}
对我来说工作很好:http://ideone.com/WERQ3H ...你能展示从创建到修改的完整代码吗? – Eric
它也适用于我。 –
@Eric :::用代码编辑问题.. –