- Trending Categories
Data Structure
Networking
RDBMS
Operating System
Java
MS Excel
iOS
HTML
CSS
Android
Python
C Programming
C++
C#
MongoDB
MySQL
Javascript
PHP
Physics
Chemistry
Biology
Mathematics
English
Economics
Psychology
Social Studies
Fashion Studies
Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
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
- Related Articles
- How to remove only last character from a string vector in R?
- Remove the last character from a string in the Swift language
- Swift Program to remove the last specified character from the string
- Python Program to remove the last specified character from the string
- How to remove the first and last character in a string in R?
- How to remove a particular character from a String.
- Find the player who is the last to remove any character from the beginning of a Binary String
- Finding the last occurrence of a character in a String in Java
- How to remove all text from a string before a particular character in R?
- C# program to remove n-th character from a string
- How to remove all common character from string array elements in android?
- How to remove the HTML tags from a given string in Java?
- Remove a character from a Java StringBuffer object
- How to remove all whitespace from String in Java?
- How to extract the last n characters from a string using Java?

Advertisements