What does a program do when it must make a decision? In this lesson we build an if/else that allows access only if age > 18. We observe how the condition evaluates to true/false using the debugger Watch, combine two conditions with && (and), and use else if to check multiple age ranges (child, youth). At the end there's an exercise to move these checks into a method that takes age and returns a String message.
Spring Boot from Scratch series episode 6 is now on the Opendart Academy YouTube channel. This series is prepared from recordings of our live Java Spring Boot course; we start from Java basics and move toward Spring Boot.
▶ Watch the lesson on YouTubeAll episodes in the series
What's in this lesson?
- 00:00 Intro
- 00:03 What does if do? Example: allow entry if age is over 18
- 00:24 if condition and scope
- 00:58 else: when the condition is not met
- 01:52 Watching the program decide in debug mode
- 03:11 When age is 17: false and the else block
- 04:08 Two conditions at once: && (and) operator
- 05:14 Multiple ranges with else if
- 05:55 Stepping through the code
- 06:41 See the condition's true/false value with Watch
- 07:17 Exercise: move the if-else into a method that returns a String
- 09:22 Closing
Opendart Academy
Learn Spring Boot with an instructor in live lessons
These videos are from the recordings of our Java Spring Boot course. The full course covers Java, Spring Boot, REST APIs, databases and real projects; you can ask the instructor when you get stuck.
← Previous: Java Methods That Return Values: return and Parameters · Playlist: Spring Boot from Scratch · Subscribe on YouTube
Instructor: İbrahim Gökyar (Opendart Academy)



