Complex conditional statements

What if we want to check and see whether our input string contains both the strings, namely sOne and sTwo? There's a couple of ways to do this, and we'll take a look at some others. But probably, the simplest way for our purposes is to use a complex conditional on the if(input.contains(sOne)) line. Java allows us to evaluate multiple true or false statements, or Boolean objects, at once using the && or the | conditional operator. The && operator gives us a true result when all conditionals compared with the && operator have evaluated to true. The | operator gives us a true result when any of the conditionals compared with the | operator evaluate to true. In our case, we want to know whether our input string ...

Get Java Programming for Beginners now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.