Write a program to find out if a string starts with and end with

Method: String.startsWith();

It will return the boolean value.

public class Main {
    public static void main(String[] args) {
        String sentence="Hello Java";
        System.out.println(sentence.startsWith("Hello"));
    }

}
Output:
true

about author

admin

salmansrabon@gmail.com

If you like my post or If you have any queries, do not hesitate to leave a comment.

Leave a Reply

Your email address will not be published. Required fields are marked *