endsWith() In Java Example
Chapter:
String Handling
Last Updated:
15-07-2016 10:35:49 UTC
Program:
/* ............... START ............... */
public class JavaStringEndsWith {
public static void main(String args[]){
String Str = new String("Welcome to JavaScan.com");
boolean booleanVal;
booleanVal = Str.endsWith( "Scan.com" );
System.out.println("Returned Value = " + booleanVal );
booleanVal = Str.endsWith( "java" );
System.out.println("Returned Value = " + booleanVal );
}
}
/* ............... END ............... */
Output
Returned Value = true
Returned Value = false
Notes:
-
This method tests if this string ends with the specified suffix.
- Syntax : boolean endsWith(String suffix)
Tags
endsWith(), Java