I have the code below. the if condition is true and it goes into the line inside the IF but when I inspect answerText later, it still has the new line at the end
if(answerText.endsWith("\n")){
answerText = answerText.substring(0, answerText.length()-2);
}