From the course: Java 8 Essential Training
Unlock the full course today
Join today to access over 22,600 courses taught by industry experts or purchase this course individually.
Programming conditional logic - Java Tutorial
From the course: Java 8 Essential Training
Programming conditional logic
In all programming lanuages writing conditional code is a common practice. Conditional code is commonly called an if then or if else statement. I've already used if statements previously in this course. It's pretty unavoidable. But now I'll go into the details of the if keyword, it's associated keyword, else and how to put these keywords together. I'll start by declaring an integer value named monthNumber and I'll give it a value of eight. Then I'll write some conditional code to evaluate it. I'll start with the keyword if. In order to evaluate a condition you place it within parenthesis. The parenthesis are required. Then you write the condition. I'm going to ask whether the monthNumber is greater than or equal to one and it's less than or equal to three. The double ampersand operator is the logical and. The double pipe character, that's the character on the backslash key, is the logical or. I'll add my braces and then I'll add some output to the console and I'll output the string…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.
Contents
-
-
-
-
-
-
-
-
-
(Locked)
Programming conditional logic3m 45s
-
(Locked)
Using the switch statement4m 51s
-
(Locked)
Creating looping code blocks5m 23s
-
(Locked)
Creating reusable code with methods4m 15s
-
(Locked)
Overloading methods with different signatures4m 51s
-
(Locked)
Passing arguments by reference or by value4m 47s
-
(Locked)
Challenge: Creating a more complex calculator application1m 53s
-
(Locked)
Solution: Creating a more complex calculator application3m 23s
-
(Locked)
-
-
-
-
-
-