Skip to main content

Posts

Featured

#18 Java for Loop

The for Loop Loops are structures used to make the program repeat one or many instructions for ‘n’ times as specified in the declaration of the loop.  The for Loop can be used for just one statement:  for(initialization; condition; iteration) statement;  or to repeat a block of code:  for(initialization; condition; iteration)  {  statement sequence  }  Initialization = assignment statement that sets the initial value of the loop control variable, (counter)  Condition = Boolean expression that determines whether or not the loop will repeat  Iteration = amount by which the loop control variable will change each time the loop is repeated.  The for loop executes only/till the condition is true. Example: using a ‘for’ loop to print the square roots of the numbers between 1 and 99. (It also displays the rounding error present for each square root). // Show square roots of 1 to 99 and the rounding error.  class SqrRoot  {  public stati

Latest Posts

#17 Java Control Statements part 4

#16 Java Control Statements Part 3

#15 Java control statements part 2

#14 Java Control Statements

#13 Java Type Casting and Conversions

#12 Java Scope And Lifetime Of Variables

#11 Java Math Class

#10 Shortcut Operators For JAVA

#9 Introducing Control Statements in JAVA

#8 Logical operators in JAVA