Which of the following ways is an efficient way of determining substring containment?
if (str.indexOf("/") > -1)
or
if (str.contains("/"))
If the goal is to determine if one String contains another, then contains() is the clear winner. It will make other developers more efficient in understanding your intent.
contains()