To get the last character of a string in Java, call
String.charAt(String.length() - 1)
.String string = "a string";
char lastCharacter = string.charAt(string.length() - 1);
System.out.println(lastCharacter); // g