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
public static void main(String[] args) {
String text_original = "wherabouts;";
char[] c = text_original.toCharArray();
System.out.println("TEXT original: "+ text_original);
String text_new = c[text_original.length()-1] == ';' ? text_original.substring(0,text_original.length()-2) : text_original;
System.out.println("TEXT new: "+text_new);
}