Here you can find the source of endsWith(final CharSequence target, final CharSequence suffix)
public static boolean endsWith(final CharSequence target, final CharSequence suffix)
//package com.java2s; //License from project: Open Source License public class Main { public static boolean endsWith(final CharSequence target, final CharSequence suffix) { if (target == null || suffix == null) { return false; }// w ww . j a v a 2 s . c om if (target == suffix) { return true; } final int suffixLength = suffix.length(); final int targetLength = target.length(); if (suffixLength > target.length()) { return false; } for (int i = 0; i < suffixLength; i++) { if (suffix.charAt(suffixLength - i - 1) != target.charAt(targetLength - i - 1)) { return false; } } return true; } }