xxxxxxxxxx
String s = "Hello Worlds";
String end = "";
end = s.substring((0, s.length()-1));
xxxxxxxxxx
String s = "Hello Worlds";
String end = "";
end = s.substring((0, s.length()-1));
xxxxxxxxxx
private static String removeLastChar(String str) {
return str.substring(0, str.length() - 1);
}
xxxxxxxxxx
public static String removeLastCharacter(String str) {
String result = null;
if ((str != null) && (str.length() > 0)) {
result = str.substring(0, str.length() - 1);
}
return result;
}
xxxxxxxxxx
String s = "blah blah <br/>";
if (s.endsWith("<br/>")) {
s = s.substring(0, s.length() - 5);
}
xxxxxxxxxx
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);
}
xxxxxxxxxx
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;
}
}