johnpaulada
10/6/2016 - 12:09 PM

ForLoop.java

public class ForLoop {
  public static void main(String[] args) {
    // Create integer array of first seven numbers of the fibonacci sequence
    int[] fibonacci = {0, 1, 2, 3, 5, 8, 13};
    
    System.out.println("Fibonacci Sequence");
    
    // Loop over each number in the array and display them.
    for (int i = 0; i < fibonacci.length; i++) {
      System.out.print(fibonacci[i] + " ");
    }
  }
}