Reputation: 33
With Java 1.5, the contains(CharSequence s) method was added to the String class. This method
Returns true if and only if this string contains the specified sequence of char values.
How would you do this in versions of Java prior to 1.5, specifically in version 1.4.2?
Upvotes: 3
Views: 18120
Reputation: 29179
To get the same effect as String.contains(substring) in Java 1.4, you can use the following snippet:
String.indexOf(substring) != -1
Upvotes: 15