Thinking Java Part I by Kaplan Randy

Thinking Java Part I by Kaplan Randy

Author:Kaplan, Randy [Kaplan, Randy]
Language: eng
Format: azw3
Published: 2018-02-05T16:00:00+00:00


Supposing we wanted to create a loop that repeated 10 times. In other words, we wanted to do something 10 times. In English we might express this as

Repeat the following code 10 times { … }

We might want to have the computer output the word “Hello” 10 times as shown below.

Hello

Hello

Hello

Hello

Hello Hello

Hello

Hello

Hello

Hello

That would look something like,

Repeat the following code 10 times { System.out.println( “Hello”; }

The sentence we will use is the “while” sentence. What can we use to count? A variable can be used to keep track of the number of times we will output “Hello.” Let’s declare an integer “count” for this purpose. The variable “count” will first be initialized to 0.



Download



Copyright Disclaimer:
This site does not store any files on its server. We only index and link to content provided by other sites. Please contact the content providers to delete copyright contents if any and email us, we'll remove relevant links or contents immediately.