 |
|
|
Rec.java
|
/*
* Author: Havard Rast Blok
* E-mail: 
* Web : www.rememberjava.com
*/
/*
* Recursive counting
*/
public class Rec
{
public Rec()
{
count( 0, 5 );
}
public void count( int i, int stop )
{
//notice the the order of the recrusive call and the print line
if( i < stop )
{
System.out.print(""+i+", ");
count( i+1, stop );
System.out.print(""+i+", ");
}
else
{
System.out.println("");
}
}
public static void main( String args[] )
{
new Rec();
}
}
|
|
|
 |