Thursday, April 14, 2016

For and While Loops


Today I made a while loop and for loop in eclipse software. Java makes it very easy to concatenate strings with integers. This technique allowed me to keep track of the amount of strings printed in the console. Another useful technique I learned was printf, this allows used to format your print. Just remember when using printf instead of println you must add \n to bring your string to a new line. For loops are very useful to understand if you want to make an android app. As you can see in our code for loops are used frequently to do steps over and over again. Below we used a for loop to select one of the bodies in our app. Inside the parenthesis the first section contains code that executes before the loop is executed. The second section is a condition, as long as it is true the loop will execute. The last section allows you to increment i. The ++ after i increases that integer by one.

No comments:

Post a Comment