In our last article, we finished our discussion of Java operators, and started to take a look at statements. In this article, we'll continue explaining Java statements. Statements aren't exactly complicated once you grasp the concept. Indeed, many statements have counterparts -- of a sort -- in real life.
As a bratty kid, do you remember you parents ever saying, “Don't make me repeat myself!” Their faces would be all red and sweaty and their eyes would spin in circles. Usually they would be pointing one enormous finger at you and you could tell by the look on their faces that they were dead serious and you had best do what they say.
Then do you remember that about five minutes later, you would completely forget what they said and suddenly they would run around the house ramming their heads into the wall and you would think: Man, my parents are crazy.
You were what Java refers to as an Iteration Statement. That's right -- a loop. You would loop that same bad behavior over every five minutes. And you even had different types of loops. Maybe you would keep asking questions, endlessly, until your parents shouted “SHUT UP!” And you probably would ask for a piece of candy and while your mom kept saying okay, you would grab more and more. Those are examples of loops.
And when your parents, after hours of struggling to be patient, finally sent you to your room without any supper, that was a break statement. Or a way to stop that cursed loop.
As you may recall, in our last article we left off discussing Selection Statements. Now, we are going to cover our other two types of statements, the Iteration and the Jump.