What is the startsWith() method?
What is the startsWith() method?
Rating:
The startsWith() method of the String class checks whether a given string starts with a specified string or not. It returns boolean true if the string matches, otherwise returns false.
The general form of this method declaration is as follows:
Here, str specifies the string being tested.
For example:
returns true as the string starts with Foo.
The other form of the startsWith() method declaration is as follows:
Here, startIndex specifies the starting index of the invoking string at which the search will begin.
For example,
returns true, as the string, ball, starts from the specified index, i.e., 4.
.
Rating:
Other articles
- Multi-Tier Applications in Java
- What are the differences between stateless and stateful session beans?
- What are numeric promotions?
- What are the new features of EJB 2.1?
- What is the purpose of the java.awt package?