Write a Write a program to check if a keyword is contained within a string.

Method to found match word is: String.contains();

public static void main(String[] args) {
        String sentence="Hello Java";
        String findString = "Java";
        Boolean found=sentence.contains(findString);
        if(found){
            System.out.println("String found");
        }
        else{
            System.out.println("String not found");
        }
    }
Output:
Hello Java
Type a word to search:

C#
String not found
Java
String found
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 *