Answers for "java string how to remove last character"

28

java remove last character from string

String s = "Hello Worlds";
String end = "";
end = s.substring((0, s.length()-1));
Posted by: Guest on October-19-2020
1

java_remove last char

public String method(String str) {
    if (str.charAt(str.length()-1)=='x'){
        str = str.replace(str.substring(str.length()-1), "");
        return str;
    } else{
        return str;
    }
}
Posted by: Guest on May-09-2021

Code answers related to "java string how to remove last character"

Code answers related to "Java"

Java Answers by Framework

Browse Popular Code Answers by Language