我想分割字符串,但由于某些原因,我收到了此错误
java.lang.ArrayIndexOutOfBoundsException: length=1; index=1
这是我的代码
string value is "88km N of Yelizovo, Russia"
String string = currentModel.getCityName();
String[] parts = string.split("of");
String part = parts[0];
String part2 = parts[1];
我例外的输出是:
part = 88km N of
part2 = Yelizovo, Russia