In this section, you will learn how to check the given string that start from the specified character in java. The following program checks the started string with "Wel". If you use startsWith() function it will return 'true' and display a message "The given string is start with Wel" otherwise it will show "The given string is not start with Wel".
Description of code:
startsWith(String start):
This is a Boolean type method that returns either 'true' or 'false'. It
checks the given string that begins with specified string in the beginning. It takes
a string type parameter such as:
start: This is the string that starts.
Here is the code of program:
import java.lang.*;
|
Output of program:
| C:\vinod\Math_package>javac StrStartWith.java C:\vinod\Math_package>java StrStartWith String start with example! Given String : Welcome to RoseIndia Start with : Wel The given string is start with Wel |
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.
Ask Questions? Discuss: String Start with Example
Post your Comment