fibonacci series using recursion in java

Below code demonstrate how to get fibonacci series using recursion in java

import java.io.*;

public class FibonacciNumbers {
public static long FibonacciMethod(long number) {
if ((number == 0) || (number == 1))
return number;
else
return FibonacciMethod(number – 1) + FibonacciMethod(number – 2);
}

public static void main(String[] args) {
try {

DataInputStream in = new DataInputStream(System.in);

System.out.print(“Enter how many number you want in series :- “);
int Number = Integer.parseInt(in.readLine());

System.out.print(“Fibonacci Series ==> “);
for (int counter = 0; counter < Number; counter++) {
System.out.print(” ” + FibonacciMethod(counter));
}
} catch (Exception e) {

System.out.println(e);
}
}
}

Output

Enter how many number you want in series :- 10
Fibonacci Series ==> 0 1 1 2 3 5 8 13 21 34