Replacing “is” with “is not” in Java
I’m in college and your professor gave us this exercise where the user should input a sentence such as “Life is great” (positiveInput in this case) and we should replace the word “is” with “is not” (negativeOutput). I know there’s probably a better way of doing it, but she wants us to do it like this. The issue is: if I write “Life is great”, the expected output is “Life is not great”, but the actual output is “Life is not s great”. Can anyone explain to me why is this extra “s” showing? I’m using StringBuffer and we have to use “append”. This is my compute method:
How StringBuffer delete works in java?
public class RemoveConsonants {