error index array out of bond exception in android
I have to create array list from string like this code
ArrayList<String> lg = new ArrayList<String>();
String[]
rl=c.getResources().getStringArray(R.array.CountryCodes);
for(int i=0;i<rl.length;i++){
String[] g=rl[i].split(",");
lg.add(g[2]);
}
CountryCodes is a string like this --> 1,US,United States
And I want to save United States to array list but it show error like this
JavaArrayIndexOutoFBond Exception in line lg.add(g[2]);
any solution??
No comments:
Post a Comment