Я пытаюсь удалить последний символ из строки, если это /
. Я использую строковый массив temp[]
для хранения строк.
Вот мой код:
char ch = ' ';
for (int st = 0; st < temp.length; st++)
{
ch = temp[st].charAt(temp[st].length()-1);
if (ch == '/')
temp[st] = temp[st].substring(0, temp[st].length()-1);
result2.append(temp[st]);
}
но я получаю
StringIndexOutOfBoundsException -1
Что я делаю не так?