Logo

Programming-Idioms

History of Idiom 39 > diff from v10 to v11

Edit summary for version 11 by :

Version 10

2015-08-21, 23:16:23

Version 11

2015-08-21, 23:17:16

Idiom #39 Check if string contains a word

Set boolean ok to true if string word is contained in string s as a substring, or to false otherwise.

Idiom #39 Check if string contains a word

Set boolean ok to true if string word is contained in string s as a substring, or to false otherwise.

Code
boolean ok = s.contains(word);
Code
boolean ok = s.contains(word);
Comments bubble
Function String.contains() exists since java 1.5
Comments bubble
Function String.contains() exists since java 1.5
Doc URL
https://docs.oracle.com/javase/8/docs/api/java/lang/String.html#contains-java.lang.CharSequence-
Demo URL
http://ideone.com/Mu2rdM
Demo URL
http://ideone.com/Mu2rdM