Exception in thread “main” java.lang.StackOverflowError

Posted: May 9, 2012 in Java

StackOverFlow Error:

This is the child class of Error and it is unchecked. Recursive method call invocation raises Stack Over Flow Error. It is JVM Exception

Example:

Public class Test{

public static void mone(){

mtwo();

}

public static void mtwo(){

mone();

}

public static void main(String… args)

{

mone();

System.out.println(“Dont get Shock”);

}}

Output:

Exception in thread “main” java.lang.StackOverflowError

at com.clarity.test1.mtwo(test1.java:78)

at com.clarity.test1.mone(test1.java:75)

at com.clarity.test1.mtwo(test1.java:78)

…………………….

(or)

public class Test {

public Test() {

this(10);

}

Test(int i){

this();

}

public static void main(String[] args) {

System.out.println(“Dont Think Too much”);

}}

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s