-5

Please see also:
How to see if a substring exists inside another string in Java 1.4
Searching for one string in another string
How to search a string in another string?

I have two strings, like so:

String str1 = "He is doing very good";
String str2 = "doing";

I want to know how to find the word "doing" in string str1, even if str1 is changed like so:

str1 = "He isdoing very good";
3

2 Answers 2

7

The easiest way would be

str1.contains(str2);
1

How about the String.contains method?

Not the answer you're looking for? Browse other questions tagged or ask your own question.