Java for loop

Java for loop program in java
 java for loop syntax
for (/* Initialization of variables */ ; /*Conditions to test*/ ; /* Increment(s) or decrement(s) of variables */) {
}

// Infinite for loop
for (;;) {
  System.out.println("Java programmer");
}
 for loop example in Java 
/*for loop to print first 10 natural numbers i.e. from 1 to 10*/

public class ForLoop {
  public static void main(String[] args) {
    int i;

    for (i = 1; i <= 10; i++) {
      System.out.println(i);
    }
  }
}

Related Posts