I have a requirement in which I need to remove the semicolon if it is present at the end of the String(only at the end). I have tried the following code. But still it is not
Use .equals() instead of == if you're going to use substring() rather than charAt():
.equals()
==
substring()
charAt()
if(text.substring(text.length()-1).equals(";"))
Also, reassign your text variable:
text = text.replaceAll(";", "");