Java String Ends With endsWith(String string, char character)

Here you can find the source of endsWith(String string, char character)

Description

ends With

License

Open Source License

Declaration

public static boolean endsWith(String string, char character) 

Method Source Code

//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);
    }
}

Related

  1. endsWith(String str, String mark)
  2. endsWith(String str, String suffix)
  3. endsWith(String str, String suffix)
  4. endsWith(String str, String suffix, boolean ignoreCase)
  5. EndsWith(String str, String suffix, int strStartPos)
  6. endsWith(String string, String... end)
  7. endsWith(String string, String... endsWithText)
  8. endsWith(String value, String[] suffixes)
  9. EndsWith(String x, String z)