Java String Ends With endsWith(String str, char suffix)

Here you can find the source of endsWith(String str, char suffix)

Description

Tests if this string ends with the specified suffix.

License

LGPL

Parameter

Parameter Description
str string to check first char
suffix the suffix.

Return

is last of given type

Declaration

public static boolean endsWith(String str, char suffix) 

Method Source Code

//package com.java2s;
//License from project: LGPL 

public class Main {
    /**/* ww w .j  av  a  2  s .c  om*/
     * Tests if this string ends with the specified suffix.
     * @param str string to check first char
     * @param suffix the suffix.
     * @return is last of given type
     */
    public static boolean endsWith(String str, char suffix) {
        return str != null && str.length() > 0 && str.charAt(str.length() - 1) == suffix;
    }

    public static int length(String str) {
        if (str == null)
            return 0;
        return str.length();
    }
}

Related

  1. endsWith(String s, String ending)
  2. endsWith(String s, String suffix)
  3. endsWith(String s1, String s2)
  4. endsWith(String source, String target, boolean caseSensitive)
  5. endsWith(String str, char c)
  6. endsWith(String str, char suffix)
  7. endsWith(String str, String end, boolean caseSensitive)
  8. endsWith(String str, String mark)
  9. endsWith(String str, String suffix)