Here you can find the source of endsWith(final String str, final char suffix)
Parameter | Description |
---|---|
str | the String to check, may be null |
suffix | the last char to find |
public static boolean endsWith(final String str, final char suffix)
//package com.java2s; public class Main { /**//from w w w. j a va 2 s .co m * Check if a String ends with a specified suffix character. <code>nulls</code> are handled * without exceptions. The comparison is case sensitive. * * <pre> * StringUtil.endsWith(null, 'a') = false * StringUtil.endsWith("", 0) = false * StringUtil.endsWith("", 'a') = false * StringUtil.endsWith("abcdef", 'f') = true * StringUtil.endsWith("ABCDEF", 'f') = false * StringUtil.endsWith("ABCDEF", 'G') = false * </pre> * * @param str * the String to check, may be null * @param suffix * the last char to find * @return true, if the String ends with the suffix */ public static boolean endsWith(final String str, final char suffix) { return str != null && str.length() > 0 && str.charAt(str.length() - 1) == suffix; } }