Java String endsWith() Method

Java String endsWith()

The endsWith() method checks whether the specified string matches the end of the given string or not.

Example

Java Compiler
public class myClass { public static void main(String[] args) { String str1 = "John doe"; String str2 = "doe"; String str3 = "do"; System.out.println(str1.endsWith(str2)); System.out.println(str1.endsWith(str3)); } }

Syntax

public boolean endsWith(String str)

Parameter Values

ValueTypeExplanation
strRequiredSpecifies the string to be matched.

Return Value

ValueExplanation
trueIf the specified string matches the end of the given string.
falseIf the specified string does not matches the end of the given string.

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author