string.startsWith()
String.startsWith() Checks the string whether it starts with input string or not.
Syntax
String1.startsWith(String2)
Return value is boolean ( true or false )
Here are some examples with output.
String my_str="plus2net";
System.out.println(my_str.startsWith("plus")); // true
System.out.println(my_str.startsWith("pl")); // true
System.out.println(my_str.startsWith("p")); // true
System.out.println(my_str.startsWith("plus2net")); // true
System.out.println(my_str.startsWith("PLUS")); // false
System.out.println(my_str.startsWith("net")); // false
System.out.println(my_str.startsWith("et")); // 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