Start Search Contents Index Links About
Rec.java
/*
 * Author: Havard Rast Blok
 * E-mail: 
 * Web   : www.rememberjava.com
 */

/*
 * Recursive counting
 */
public class Rec
{

  public Rec()
  {
    countBack11);
    countBack25);
  }

  public void countBack1int i, int stop )
  {
    //notce the the order of the recrusive call and the print line

    ifi < stop )
    {
      countBack1i+1, stop );
      System.out.println(""+i);
    }
  }

  public void countBack2int i, int stop )
  {
    ifi >= stop )
    {
      System.out.println(""+i);
      countBack2i-1, stop );
    }
  }

  public static void mainString args[] )
  {
    new Rec();
  }

}


site: Håvard Rast Blok
mail:
updated: 27 July 2007