Friday, 30 December 2016

For Loop In Java Example

package com.kt4study.corejava.loop;

/**
 @author kt4study.blogspot.co.uk
 
 */

public class ForLoopExample {
  
  public static void  forLoopExampleDemo(){
    
    //initialization, condition check, Increment/Decrement
    for(int i = 0; i<4; i++){
      System.out.println("Current value of 'i' is :: " + i);
    }
  }
  
  public static void main(String[] args) {
    ForLoopExample.forLoopExampleDemo();
  }
}

Output →

Current value of 'i' is :: 0
Current value of 'i' is :: 1
Current value of 'i' is :: 2
Current value of 'i' is :: 3

No comments:

Post a Comment