Before changing anything in the given code . i would like to know the cause of having a stack over flow . What I already know is : Having stackOverFlow error means that the the amount of stack space required by the program exceeds what is configured for the stack in the Java virtual machine . But here i see none of the see. I don't see an unending loop or something like that !