JavaScript
Java vs JavaScript: Most Important Differences You Must Know
What is Java? Java is a multi-platform, object-oriented, and network-centric, programming...
The Java String endsWith() method is used to check whether the string is ending with user-specified substring or not. Based on this comparison it returns the result in boolean value true if the specific suffix is matched or it returns false if the suffix does not match.
Syntax
Public endsWith(suffix)
Parameters
suffix – This is a suffix.
Return Value
Exception
None
Example:
public class StringEx1 {
public static void main(String[] args) {
String str_Sample = "Java String endsWith example";
//Check if ends with a particular sequence
System.out.println("EndsWith character 'e': " + str_Sample.endsWith("e"));
System.out.println("EndsWith character 'ple': " + str_Sample.endsWith("ple"));
System.out.println("EndsWith character 'Java': " + str_Sample.endsWith("Java"));
}
}
Output:
EndsWith character 'e': true
EndsWith character 'ple': true
EndsWith character 'Java': false
The java.lang.String.endsWith() returns true if this string ends with the specified suffix.
What is Java? Java is a multi-platform, object-oriented, and network-centric, programming...
What is Java? Java is a multi-platform, object-oriented, and network-centric, programming...
Java String contains() method The Java String contains() method is used to check whether the...
What is Java? Java was released by Sun Microsystem in 1995. It was developed by James Gosling. It is a...
What is a Build Tool? A build tool is a programming tool which is used to build a new version of a...
What is Command Line Argument in Java? Command Line Argument in Java is the information that is...