的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 :::用代碼編輯問題.. –