public class
Testing {
public static void main(
String args[] ) {
String s = "SA001^SFO^DEN^SpeedyAir^400^Sun^13:40^20m^50";
String[] s2 = new String[9];
int aIndex = s.indexOf('^');
int bIndex = 0;
int cIndex = -1;
for( int i = 0; i < 9; i++ )
{
if( bIndex == -1 )
{
s2[i] = s.substring( ++cIndex );
break;
}
s2[i] = s.substring( ++cIndex, aIndex );
cIndex = aIndex;
bIndex = s.indexOf('^', aIndex );
aIndex = bIndex;
}
System.out.println( s2 );
}
}
The main purpose of this class is to convert the String object to an array of Strings.
But the compiler complains of String index out of Bonds exception.
please clarify this for me.
poornima.