Introduction
So far, we have looked at programs that consist of a series of statements that the Java compiler executes sequentially. However, in certain cases, we might need to perform actions based on the current state of the program.
Consider the example of the software that's installed in an ATM machine – it performs a set of actions, that is, it allows a transaction to occur when the PIN that's been entered by the user is correct. However, when the PIN that's been entered is incorrect, then the software performs another set of actions, that is, it informs the user that the PIN does not match and asks the user to reenter the PIN. You'll find that such logical constructs that depend upon values or stages are present in almost all real-world programs.
There are also times where a particular task might need to be performed repeatedly, that is, for a particular time duration, for a particular set number of times, or until a condition is met. Continuing from our example of the ATM machine, if the number of times an incorrect password is entered exceeds three, then the card is blocked.
These logical constructs act as building blocks, as we move toward building complex programs in Java. This lesson will dive into these basic constructs, which can be categorized into two general classes, as follows:
- Conditional statements
- Looping statements
- Learning LibGDX Game Development(Second Edition)
- Learn to Create WordPress Themes by Building 5 Projects
- aelf區塊鏈應用架構指南
- Python編程實戰
- Java SE實踐教程
- 軟件供應鏈安全:源代碼缺陷實例剖析
- Learning AWS
- 微課學人工智能Python編程
- Distributed Computing in Java 9
- Scala Functional Programming Patterns
- Learning D
- Java EE程序設計與開發實踐教程
- Scratch編程入門與算法進階(第2版)
- 算法技術手冊
- R Data Visualization Cookbook