In this article, we will see how to use contains method of String class in Java.
In Java, Strings, we can use contains method to find word within a text.
Lets look to our code.
String x = "a b c";
System.out.println(x.contains("b"));
Lets see it in an example.
In above example, we created two String object. We used contains method in our string to find if "galaxy" word exist in sentence. Method returned true.