Check If String Contains String Java Code Example


Example 1: string contains specific word in java

str_Sample.contains("Example"));

Example 2: check if a string contains a character java

string.indexOf('a')

Example 3: string contains specific word in java

public boolean String.contains(CharSequence s);

Example 4: string check if substring exists java

String str1 = "Java"; String str2 = "va";  if(str1.contains(str2)){   // str1.contains(str2) will be true here.   System.out.println("I am true"); }

Comments

Popular posts from this blog

Chemistry - Bond Angles In NH3 And NCl3

Are Regular VACUUM ANALYZE Still Recommended Under 9.1?

Change The Font Size Of Visual Studio Solution Explorer