Theres an exercise from a Java book I'm reading that has me confused:

> 
> A Fibonacci sequence is the sequence of numbers 1, 1, 2, 3, 5, 8,
>  13, 21, 34, etc., where each number (from the third on) is the sum
>  of the previous two. Create a method that takes an integer as an 
>  argument and displays that many Fibonacci numbers starting from the
>  beginning. If, e.g., you run java Fibonacci 5 (where Fibonacci is
>  the name of the class) the output will be: 1, 1, 2, 3, 5.
> 
> 
> 

I could have swore that it would need an array or some way of storing the previous numbers but when I saw the answer it wasn't the case:

```
import java.util.*; 

public class Fibonacci { 

    static int fib(int n) {
         if (n <= 2) 
              return 1;

         return fib(n-1) + fib(n-2);
    } 
    public static void main(String[] args) {
    // Get the max value from the command line: 
    int n = Integer.parseInt(args[0]); 
    if(n < 0) {
        System.out.println("Cannot use negative numbers"); return;
    } 
    for(int i = 1; i <= n; i++)
        System.out.print(fib(i) + ", ");
    }
}

```

Would someone be able to explain how using a function within itself produces this?