How to remove the last character of a string in Java

1 Answer

0 votes
public class MyClass {
    public static void main(String args[]) {
        String str = "java programming";

        str = str.substring(0, str.length() -1);

        System.out.println(str);
    }
}




/*
run:

java programmin

*/

 



answered Feb 8, 2021 by avibootz

Related questions

...