Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations sizbut on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

String Manipulation - String Containment

Status
Not open for further replies.

DB2Problem

Programmer
Oct 17, 2002
53
US
Hello,

I have string variables and i want to test the containment of one string in other

For Example

String a = "microsoft software";
String b = "abcd microsoft software efgh";

How can i test that string b contains string a ? String b has string a but it can be anywhere with in string b.

Please help with this code.

Thanks a lot
 
Javadocs: String
public boolean contains(String s)

Returns true if and only if this string contains the specified string.
Code:
if (b.contains (a)) 
    // your code here...
 
I've got to say here - RTFM - have you even bothered to read the fine manual ?!

The "equals" method may be of interest ...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top