Stack Overflow

Stack Overflow

Table of contents

Introduction

  1. When we have any function at run time when its execution starts it gets loaded in the stack, as soon as its execution is over the method is taken out.
  2. In Java main is also a function.
  3. As all functions are loaded on the stack for their execution, the same main method is also loaded.
  4. The length of the stack is always fixed, if we try to execute it we will get a stack overflow error.
  5. When we make a call to main inside the main function, what will happen is we will get stack overflow error.
  6. Here what is happening is everytime when we also called main , like a recursive calls.
  7. Infinite number of recursive calls without a break will lead to stack overflow error.