/** * @author lautturi.com * Java example: remove the last character of string in java */ import java.util.*; public class Lautturi { public static void main(String[] args) { String str = "Hello World!"; System.out.println(str); str = str.substring(0, str.length()-1); System.out.println(str); } }Source:www.lautturi.com
output:
Hello World! Hello World