Java String endsWith Example
String class endsWith method example
String class endsWith method example. This example shows you how to use endsWith method.This method Tests if this string ends with the specified suffix.
Syntax:-endsWith(String suffix)
Here is the code:-
/**
* @(#) EndsWithstring.java
*Program to tests if this string ends with the specified suffix.
* @Version 01-May-2008
* @author Rose India Team
*/
public class EndsWithstring
{
public static void main(String[] args)
{
String str1 = "RoseIndia is my Team";
// String to check the above String to see if they end with this value (r).
String checkstring = "m";
/* Checking if either of the above Strings ends with 'R'or not..
boolean is taken so that it may return true and false*/
boolean s1 = str1.endsWith(checkstring);
// Display the results of the endWith calls.
System.out.println("\"" + str1 + "\"ends With " +
"\"" + checkstring + "\":- " + s1);
}
} |
null
|