O'Reilly logo

Java Programming for Beginners by Mark Lassoff

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required