string.endsWith()
String.endsWith() Checks the string whether it ends with input string or not.
Syntax
String1.endsWith(String2)
Return value is boolean ( true or false )
Here are some examples with output.
String my_str="plus2net";
System.out.println(my_str.endsWith("2net")); // true
System.out.println(my_str.endsWith("et")); // true
System.out.println(my_str.endsWith("t")); // true
System.out.println(my_str.endsWith("plus2net")); // true
System.out.println(my_str.endsWith("NET")); // false
System.out.println(my_str.endsWith("plus2")); // false
System.out.println(my_str.endsWith("pl")); // false
This is case sensitive matching of end part of the string.
« All String functions
« Java
This article is written by plus2net.com team.
plus2net.com