In this video, Doug Winnie shows how to create complex conditional tests using the logical operators AND (&&) and OR (||) in Java. In addition, Doug shows how to group tests together to create even more complex tests and how to use the NOT (!) operator to reverse a Boolean value.
- [Instructor] In Java, logic operators…like and and or are used to combine in multiple…equality evaluations together to create…compound conditional tests.…In Java, the or operator is a double pipe.…Which is the shift backslash key on the keyboard.…We can create a simple or test using literal…Boolean values.…We'll start with an if statement.…And we'll ask if true or false then we'll create…our code block.…
System dot out dot print ln only one value…needs to be true in an or statement for the whole…evaluation to be true.…In this example, we have a literal true and false…that are being tested using the or operator.…Since only one needs to be true,…the entire evaluation is evaluated as true.…
Build and run the program to see the output.…For an and test, we use the double ampersand.…So we'll do one here.…If true and false, and we'll create…just a comment in that one, and then we'll do…an l statement.…System dot out dot print ln, both values need to…be true for an and statement to be true.…
Because only one of the values is true,…
- The history of Java
- Setting up your development environment
- Working with values and variables
- Using methods and functions
- Capturing user input
- Creating conditional tests
- Using loops
- Creating and changing arrays
- Object-oriented programming in Java
- Defining permissions
- Extending classes
Skill Level Beginner
Computer Science Principles: The Internetwith Doug Winnie59m 30s Beginner
Java Essential Training for Studentswith Peggy Fisher3h 6m Intermediate
1. Intro to Java
2. Define Actions Using Code
3. Repeat Actions and Test for Conditions
4. Object-Oriented Programming Basics
Next steps1m 44s
- Mark as unwatched
- Mark all as unwatched
Are you sure you want to mark all the videos in this course as unwatched?
This will not affect your course history, your reports, or your certificates of completion for this course.Cancel
Take notes with your new membership!
Type in the entry box, then click Enter to save your note.
1:30Press on any video thumbnail to jump immediately to the timecode shown.
Notes are saved with you account but can also be exported as plain text, MS Word, PDF, Google Doc, or Evernote.