I am trying to remove the last character from a string, if it is a /. I am using a string array, temp[], to store the strings.
Here's my code:
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]);
}
but i am getting
StringIndexOutOfBoundsException -1
What am I doing wrong?
Remove Last Character if it is / java
str = str.replaceAll("/$", "");
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With