Article Categories
- All Categories
-
Data Structure
-
Networking
-
RDBMS
-
Operating System
-
Java
-
MS Excel
-
iOS
-
HTML
-
CSS
-
Android
-
Python
-
C Programming
-
C++
-
C#
-
MongoDB
-
MySQL
-
Javascript
-
PHP
Selected Reading
How to remove the last character from a string in Java?
The StringBuffer class contains a method known as deleteCharAt(). This method deletes the character at a specified index/position. You can use this method to delete/remove a particular character from a string in Java.
Example
public class Test {
public static void main(String args[]){
String str = "hi welcome to Tutorialspoint";
StringBuffer sb= new StringBuffer(str);
sb.deleteCharAt(sb.length()-1);
System.out.println(sb);
}
}
Output
hi welcome to Tutorialspoint
Advertisements
