xxxxxxxxxx
private static String removeLastChar(String str) {
return str.substring(0, str.length() - 1);
}
xxxxxxxxxx
String s = "Hello Worlds";
String end = "";
end = s.substring((0, s.length()-1));
xxxxxxxxxx
if (fieldName.endsWith(",")) {
fieldName = fieldName.substring(0, fieldName.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 = "Hello Worlds";
String end = "";
end = s.substring((0, s.length()-1));
xxxxxxxxxx
String s = "blah blah <br/>";
if (s.endsWith("<br/>")) {
s = s.substring(0, s.length() - 5);
}
xxxxxxxxxx
const bookName = 'Atomic Habits' // 13 characters (indexes between 0 and 12)
const newBookName = bookName.slice(0, bookName.length - 1) // Between (0 and 12)
console.log(newBookName)
// Output: "Atomic Habit"
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);
}