1var str = "Hello";
2var newString = str.substring(0, str.length - 1); //newString = Hell
1String string = "Hello World";
2
3//Remove first character
4string.substring(1); //ello World
5
6//Remove last character
7string.substring(0, string.length()-1); //Hello Worl
8
9//Remove first and last character
10string.substring(1, string.length()-1); //ello Worl
1private static String removeLastChar(String str) {
2 return str.substring(0, str.length() - 1);
3}