October 2017
Beginner
318 pages
7h 26m
English
To help us with what we discussed in the preceding section, we have the boolean variable:
boolean bool = true;
In the preceding line of code, boolean is a primitive type in Java, and a variable of the boolean type can have only one of the two values: it can be either true or false. We can set the value of our Boolean variables to be any conditional statement. So, if we wanted to simplify how our code looks in the actual if statement, we could go ahead and store these Boolean values:
boolean bool1 = input.contains(sOne); boolean bool2 = input.contains(sTwo);
We need to do this before we actually evaluate the if statement, keeping everything much more compact and readable:
if((bool1 || bool2) && false)
Read now
Unlock full access