Java String.endsWith() Method Example

The String.endsWith(String suffix) Method

This method tests if this string ends with the specified suffix. Returns true if the character sequence represented by the argument is a suffix of the character sequence represented by this object; false otherwise.

Java String.endsWith() Method Example

public class EndsWithExample {
    public static void main(String[] args) {
        String str = "javaguides";
        String subStr = "guides";
        boolean endsWith = str.endsWith(subStr);
        System.out.println(str + " endsWith " + subStr +"  :: " + endsWith);
    }
}

Output:
javaguides endsWith guides:: true 

Reference


Free Spring Boot Tutorial - 5 Hours Full Course


Watch this course on YouTube at Spring Boot Tutorial | Fee 5 Hours Full Course