Here you can find the source of endsWithChar(String string, char suffix)
Parameter | Description |
---|---|
string | the <code>String</code> to check |
suffix | the suffix to find |
true
if the char
is a suffix of the given String
; false
otherwise.
public static boolean endsWithChar(String string, char suffix)
//package com.java2s; // License as published by the Free Software Foundation; either public class Main { /**//from w w w . ja v a 2 s. com * Tests if this string ends with the specified suffix. * <p/> * It is faster version of {@link String#endsWith(String)} optimized for one-character * suffixes at the expense of some readability. Suggested by SimplifyStartsWith PMD rule: * http://pmd.sourceforge.net/pmd-5.3.1/pmd-java/rules/java/optimizations.html#SimplifyStartsWith * * @param string the <code>String</code> to check * @param suffix the suffix to find * @return <code>true</code> if the <code>char</code> is a suffix of the given * <code>String</code>; <code>false</code> otherwise. */ public static boolean endsWithChar(String string, char suffix) { return string.length() > 0 && string.charAt(string.length() - 1) == suffix; } }