When java.lang.StackOverflowError occurs in java

What is hierarchy of java.lang.StackOverflowError?


StackOverflowError is Checked (compile time exceptions) and UnChecked (RuntimeExceptions) in java ?

java.lang.StackOverflowError is a Error in java. Error and its subclasses are regarded as unchecked exceptions .

What is StackOverflowError in java?

StackOverflowError is thrown when a stack overflow occurs because an application recurses too deeply.

Scenarios where StackOverflowError may be thrown in java>

If method is called recursively StackOverflowError is thrown.

/** Copyright (c), AnkitMittal JavaMadeSoEasy.com */
public class ExceptionTest {
   public static void main(String[] args) {
          m(); //call recursive method m()
          System.out.println("Code after exception handling");
   static void m() {
          try {
                 //method m() calls itself recursively
          } catch (StackOverflowError e) {
   at ExceptionTest.m(ExceptionTest.java:18)
Code after exception handling

No comments:

Post a Comment

Related Posts Plugin for WordPress, Blogger...
//start paginationJs //end paginationJs