Here you can find the source of endsWith(CharSequence str, char suffix)
public static boolean endsWith(CharSequence str, char suffix)
//package com.java2s; /*!// ww w .j av a 2s. c o m * mifmi-commons4j * https://github.com/mifmi/mifmi-commons4j * * Copyright (c) 2015 mifmi.org and other contributors * Released under the MIT license * https://opensource.org/licenses/MIT */ public class Main { public static boolean endsWith(CharSequence str, char suffix) { if (str == null) { return false; } if (str.length() < 1) { return false; } char lastCh = str.charAt(str.length() - 1); return (lastCh == suffix); } public static boolean endsWith(CharSequence str, CharSequence suffix) { if (str == null) { return false; } if (suffix == null || suffix.length() == 0) { return true; } int len = suffix.length(); int offset = str.length() - len; if (offset < 0) { return false; } for (int i = 0; i < len; i++) { char ch = str.charAt(i + offset); char suffixCh = suffix.charAt(i); if (ch != suffixCh) { return false; } } return true; } public static CharSequence endsWith(CharSequence str, CharSequence... suffixes) { if (str == null) { return null; } if (suffixes == null || suffixes.length == 0) { return null; } for (CharSequence suffix : suffixes) { if (endsWith(str, suffix)) { return suffix; } } return null; } }