How to access a String Array location in android?
Posted
by
Vamsi Challa
on Stack Overflow
See other posts from Stack Overflow
or by Vamsi Challa
Published on 2012-12-08T16:48:47Z
Indexed on
2012/12/08
17:03 UTC
Read the original article
Hit count: 285
Android 2.3.3
This is my code...
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
Can someone help me with this.. Can we access the index 0, directly as i am doing?
Actual Code :::
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;
}
© Stack Overflow or respective owner