Considering the semantics of the problem, String#contains(...) is a better choice than String#indexOf(...) and has the added advantage of not requiring a secondary comparison with -1.

db