fork(20) download
  1. public class Main
  2. {
  3. public static void main (String[] args) throws java.lang.Exception
  4. {
  5. String s1 = "Remove Last CharacterY";
  6. String s2 = "Remove Last Character2";
  7. System.out.println("After removing s1==" + removeLastChar(s1) + "==");
  8. System.out.println("After removing s2==" + removeLastChar(s2) + "==");
  9. }
  10.  
  11. public static String removeLastChar(String str) {
  12. return removeLastChars(str, 1);
  13. }
  14.  
  15. public static String removeLastChars(String str, int chars) {
  16. return str.substring(0, str.length() - chars);
  17. }
  18. }
Success #stdin #stdout 0.14s 36000KB
stdin
Standard input is empty
stdout
After removing s1==Remove Last Character==
After removing s2==Remove Last Character==