This small program simply allows the user to call two different methods passing along an interger value to each. One method will output numbers from zero utnil that integer value using iteration. The other method outputs numbers from zero to that integer using recursion.

public class Main {

    public Main() {
    public static void main(String[] args) {
        Main demo = new Main();
    public void iterativeMethod(int x){
        for(int i=0; i<=x; i++){
            System.out.println("The iterative number is "+i);
    public int recursionMethod(int x){
        int call;    
            call = recursionMethod(x-1)+1;
            System.out.println("The recursive number is "+call);
        return x;

I'm new to Java. This has actually been the first time I've seen a constructor method for main. Looks good, and it's a good way to explain recursion.