remove last character from string java

58

remove last character from string -

let str = "12345.00";
str = str.substring(0, str.length - 1);

remoce last character froma java string -

str = str.substring(0, str.length() - 1);

remove last character from string java -

public static String removeLastChar(String str) {
    return removeLastChars(str, 1);
}

public static String removeLastChars(String str, int chars) {
    return str.substring(0, str.length() - chars);
}

Comments

Submit
0 Comments