Need Help - StackOverflowError - Fibonacci
I'm creating a Fibonacci sequence for a program. The instructions are as follows: "Write a recursive method to compute a fibonocci series. Start at a user supplied starting point and continue 10 places."
When compiled, the method shows no errors. However, when tested, the bolded line returns the following error: "java.lang.StackOverflowError: null(in java.lang.Stringbuilder)"
public class Fibonacci
static String series = "";
static String input = "";
public static void main(String args)
input = JOptionPane.showInputDialog(null, "Enter an integer.");
int start = Integer.parseInt(input);
JOptionPane.showMessageDialog(null, "The series is \n" + series);
/** Computes a fibonocci series starting at a user supplied integer and continuing 10 places. */
public static String fib(int x, int y)
int i = 0;
int result = 0;
if(i < 2)
result = x;
y = x;
result = x + y;
y = x;
x = result;
[B] series += ", " + result;[/B]
if(i < 10)
As you can tell, I'm quite new to java. I don't know if I'm just not understanding the problem, or if I am, but just going about it the wrong way. Any help is appreciated.