write a program to print a word by deleting 1 letter from end in each turn
Answers
Answered by
1
import java.util.*;
import java.lang.*;
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);
}
}
himanshu224:
kya app isko acchi tereh se likh kar de sakte ho kya
Similar questions