How do I remove a character from a string in java?



How do I remove a character from a string in java?..

Answer / Sukhvir Singh

You can remove a character from a string in Java by using the `substring()` method and creating a new string without the unwanted character. For example, `str.substring(0, indexOfTheCharToRemove) + str.substring(indexOfTheCharToRemove + 1)`. Alternatively, consider using `StringBuilder` for efficient string manipulation.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More Core Java Interview Questions

What is meant by design patterns?

1 Answers  


How many bits are used to represent unicode, ascii, utf-16, and utf-8 characters?

1 Answers  


What is the superclass of exception?

3 Answers  


can you program for reverse string?

7 Answers   IBM,


Which method must be implemented by all threads?

1 Answers  


How many JVMs can run on a single machine and what is the meaning of Just-In-Time (JIT) compiler?

1 Answers   TCS,


What is collection sort in java?

1 Answers  


What are autoboxing and unboxing? When does it occur?

1 Answers  


What is user defined exception?

4 Answers  


When a thread is executing a synchronized method , then is it possible for the same thread to access other synchronized methods of an object ?

1 Answers  


What is JFC?

1 Answers  


What is the difference between java applets and applications?

1 Answers  


Categories