官术网_书友最值得收藏!

  • Java Fundamentals
  • Gazihan Alankus Rogério Theodoro de Brito Basheer Ahamed Fazal Vinicius Isola Miles Obare
  • 230字
  • 2021-06-11 13:37:56

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
主站蜘蛛池模板: 泊头市| 玉田县| 明水县| 德清县| 永年县| 遂昌县| 平舆县| 岫岩| 南投县| 莒南县| 湛江市| 乌鲁木齐县| 沂源县| 黄浦区| 唐山市| 弥勒县| 洪泽县| 达拉特旗| 兴化市| 塔河县| 景德镇市| 义乌市| 中方县| 清水河县| 子洲县| 上犹县| 合江县| 望奎县| 太仆寺旗| 太原市| 肥东县| 晋城| 平凉市| 新竹市| 曲阳县| 松桃| 安泽县| 灵宝市| 襄垣县| 宜宾县| 泰兴市|