How can java (android) detect the presence of a word in a string? For example, there is a line:

String str = "наличие слова в строке"; 

I enter "words" and if it is, the function returns true, otherwise false.

    2 answers 2

     boolean checkForWord(String line, String word){ return line.contains(word); } 

      See String.contains ()

       str.contains("слов")