Vou deixar uns exemplos aqui pra voce entender como funciona...
"abcdef".endsWith("def")
true
"abcdef".endsWith("ef")
true
String a = "bom dia";
String b = "dia";
a.endsWith(b)
true
String a = "bom dia";
String b = "dia";
b.endsWith(a)
false
Abraços!
Fórum