Java String contains Example
String class contains method example
String class contains method example. This example shows you how to use contains method.This method Returns true if and only if this string contains the specified sequence of char values.
Syntax:-contains(CharSequence s)
Here is the code:-
/**
* @(#) ContainsString.java
*Program that Returns true if and only if this string contains the specified sequence of char values.
* @Version 01-May-2008
* @author Rose India Team
*/
class ContainsString
{
public static void main(String[] args)
{
//Declaration of first string
String str1 = "Welcome to RoseIndia";
//Returns true if and only if this string contains the specified sequence of char values.
boolean equals1 = str1.contains("Welcome");
System.out.println(equals1);
}
} |
null
|