Java entfernen Sie das letzte Zeichen aus String
String s = "Hello Worlds";
String end = "";
end = s.substring((0, s.length()-1));
Concerned Capybara
String s = "Hello Worlds";
String end = "";
end = s.substring((0, s.length()-1));
private static String removeLastChar(String str) {
return str.substring(0, str.length() - 1);
}
str = str.substring(0, str.length() - 1);
String str = "India";
System.out.println("last char = " + str.charAt(str.length() - 1));
let str = "12345.00";
str = str.substring(0, str.length - 1);
import java.util.*;
class LastCharRemove
{
public static void main(String str[])
{
Scanner sc=new Scanner(System.in);
String str1=sc.nextLine();
int n=str1.length();
StringBuilder b= new StringBuilder();
b.append(str1);
b.delete(n-1,n);
System.out.println(b.toString());
}
}