In Apex, the endsWith() method is used to return true if the given string ends with the prefix provided in the method.
endsWith()
Here's an example:
String s = 'Hello Jason'; System.assert(s.endsWith('Jason'));
Output: true