Alex Rivera | Logout

How to remove single character from a String by index

Asked 2012-11-14T19:42:28.517
168

For accessing individual characters of a String in Java, we have String.charAt(2). Is there any inbuilt function to remove an individual character of a String in java?

Something like this:

if(String.charAt(1) == String.charAt(2){
   //I want to remove the individual character at index 2. 
}
Edit
Report

1 Answer

1

Use replaceFirst function of String class. There are so many variants of replace function that you can use.

answered 2012-11-14T19:44:40.143

Your Answer