// A Java application that prints a "bar graph" of the first 9 Fibonacci
// numbers.
// Fib[i] = Fib[i-2] + Fib[i-1], for i >= 2.
class BarGraphFib {
public static void main( String[] args ) {
String[] barGraph; // Declaring an array (reference) variable
barGraph = new String[10]; // Allocating the space for the array
barGraph[0] = "";
barGraph[1] = "*";
System.out.println( 1 + ": " + barGraph[1] );
for (int i = 2; i < barGraph.length; i++){ // Note loop termination
barGraph[i] = barGraph[i-2] + barGraph[i-1];
System.out.println( i + ": " + barGraph[i] );
}
}
}