Java: Read a string and returns after removing a specified character and its immediate left and right characters
Write Java program to read a string and return after removing specified characters and their immediate left and right adjacent characters.
Visual Presentation:
Sample Solution:
Java Code:
Sample Output:
The given strings is: test#string The new string is: testring The given strings is: test##string The new string is: testring The given strings is: test#the#string The new string is: teshtring
Flowchart:
For more Practice: Solve these Related Problems:
- Write a Java program to remove occurrences of a specific character along with its immediate left and right neighbors.
- Write a Java program to delete a target character and its adjacent characters using iterative processing.
- Write a Java program to filter out a specified character and the characters directly adjacent to it from a string.
- Write a Java program to remove a designated character along with one character on its left and right, handling overlapping cases.
Java Code Editor:
Improve this sample solution and post your code through Disqus
Previous: Write a Java program to read a string and if one or both of the first two characters is equal to specified character return without those characters otherwise return the string unchanged.
Next: Write a Java program to return the substring that is between the first and last appearance of the substring 'toast' in the given string,or return the empty string if substirng 'toast' does not exists.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.