How to remove the last character from a string?
This video explains how to do that in Java, WE using the substring() method to achieve that
Below is the program
public class StringTutorial {
public static void main(String args[]){
String name=”Spring,”;
System.out.println(“before:”+name);
String newname=name.substring(0, name.length()-1);
System.out.println(“after:”+newname);
String newname2=name.substring(name.length()-1);
System.out.println(“after2:”+newname2);
}
}
java
Xem Thêm Bài Viết Về Mobile Khác: https://sealsystem.org/mobile
Nguồn: https://sealsystem.org/