11 May String endsWith(String suffix) method in Java
The boolean endsWith(String suffix) method in Java tests if this string ends with the specified suffix.
Syntax
Let us see the syntax,
boolean endsWith(String suffix)
Parameters
Let us see the parameters,
- suffix – string for suffix
Example
The following is an example of endsWith(String suffix),
public class StudyopediaDemo {
public static void main(String args[]) {
boolean result;
String message = new String("Welcome to Studyopedia");
result = message.endsWith( "Study" );
System.out.println("Result: " + result );
result = message.endsWith( "Studyopedia" );
System.out.println("Result: " + result );
result = message.endsWith( "pedia" );
System.out.println("Result: " + result );
}
}
Output
The following is the output,

No Comments