Note the StringUtils # containsAny method

Note that containsAny in the ʻorg.apache.commons.lang3.StringUtils` class has some overloaded methods, but behaves addictively.

The second argument is CharSequence

public static boolean containsAny(final CharSequence cs, final CharSequence searchChars) 

The method of is true if any character contained in the string of the second argument is included.

//Example
StringUtils.containsAny("abcde", "aaa"); // true

StringUtils.containsAny("abcde", "efghi"); // true

The second argument is CharSequence ...

public static boolean containsAny(final CharSequence cs, final CharSequence... searchCharSequences)

The method of is true if any string contained in the string array of the second argument is included. (This time, the behavior we expected)

//Example
StringUtils.containsAny("abcde", "aaa", "bbb", "ccc"); // false

StringUtils.containsAny("abcde", "cde", "def", "efg"); // true

Although it is a variable argument method, the behavior changes only when the number of arguments is 1 (it looks like), so it seems that variations will increase in the future, so it is notStringUtils.contains ()butStringUtils.containsAny () Be careful not to get addicted to the simple idea ofmaking it.

You can call the variable argument method by forcibly casting as follows.

StringUtils.containsAny("abcde", new String[]{"aaa"}); // false

StringUtils.containsAny("abcde", new String[]{"efghi"}); // false

Recommended Posts

Note the StringUtils # containsAny method
About the method
Output about the method # 2
About the length method
About the authenticate method.
About the map method
About the ancestors method
About the to_s method.
What is the pluck method?
Output about the method Part 1
about the where method (rails)
A note about the scope
Understand the helper method form_with
Consideration about the times method
What is the initialize method?
How to use the link_to method
Simulate the simplex method with GUI
How to use the include? method
How to use the form_with method
[Note] Self-made code trace history method
Note on the path of request.getRequestDispatcher
Java comparison using the compareTo () method
I tried to explain the method
About the role of the initialize method
[Rails 6] destroy using the resources method
Was that so, the user_signed_in? method
Call the super method in Java