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 versi开发者_如何学Goon 1.4.2?
To get the same effect as String.contains(substring) in Java 1.4, you can use the following snippet:
String.indexOf(substring) != -1
精彩评论