Well, why not just check if sentence.indexOf("A")==sentence.length()-1?

That statement says: if the index of A is the last index

The reason it says that is because sentence.length() returns the...