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,
1 2 3 |
boolean endsWith(String suffix) |
Parameters
Let us see the parameters,
- suffix – string for suffix
Example
The following is an example of endsWith(String suffix),
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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