String End with Example

This section tells you, how to determine the given
string ends with specified string. The following program helps you to check whether the given string starts with the specified string is true or false by applying
endsWith() method and returns Boolean types values either 'true' or 'false'. If it returns 'true', it will display a message
"The given string is end with RoseIndia" otherwise it shows
"The given string is not end with RoseIndia".
Description of code:
endsWith(String end):
This is a Boolean type method that returns
either 'true' or 'false'. It checks the given string that end with
specified string in end. It takes string type parameter like:
end: This is
the string that is ended.
Here is the code of program:
import java.lang.*;
public class StrEndWith{
public static void main(String[] args) {
System.out.println("String end with example!");
String str = "Welcome to RoseIndia";
String end = "RoseIndia";
System.out.println("Given String : " + str);
System.out.println("End with : " + end);
if (str.endsWith(end)){
System.out.println("The given string is end with RoseIndia");
}
else{
System.out.println("The given string is not end with RoseIndia");
}
}
}
|
Download this example.
Output of program:
C:\vinod\Math_package>javac StrEndWith.java
C:\vinod\Math_package>java StrEndWith
String end with example!
Given String : Welcome to RoseIndia
End with : RoseIndia
The given string is end with RoseIndia |

|
Current Comments
0 comments so far (post your own) View All Comments Latest 10 Comments: