The "contains (CharSequence s)" method in the String class in JDK 1.4.2

In Java 1.5, the String class has been added (CharSequence s) . 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, in particular in version 1.4.2?

+2
source share
1 answer

To get the same effect as String.contains (substring) in Java 1.4, you can use the following snippet:

String.indexOf(substring) != -1 
+13
source

Source: https://habr.com/ru/post/1337138/


All Articles