Java tutorial
public class Main { public static void main(String[] args) throws java.lang.Exception { String s1 = "Remove Last CharacterY"; String s2 = "Remove Last Character2"; System.out.println("After removing s1==" + removeLastChar(s1) + "=="); System.out.println("After removing s2==" + removeLastChar(s2) + "=="); } private static String removeLastChar(String str) { return str.substring(0, str.length() - 1); } }