Here you can find the source of endsWith(String string, char character)
public static boolean endsWith(String string, char character)
//package com.java2s; //License from project: Open Source License public class Main { public static boolean endsWith(String string, char character) { return lastChar(string) == character; }//from w w w .j a va 2 s.co m public static char lastChar(String string, int fromLast) { if (fromLast < 0 || fromLast >= string.length()) { throw new StringIndexOutOfBoundsException( "fromLast must be a positive integer " + "smaller than the length of string"); } return string.charAt(string.length() - fromLast + 1); } public static char lastChar(String string) { return string.charAt(string.length() - 1); } }