Hi ,
When I tried to execute the following code, I got an error which is presented down.
public class Test {
public static void main(String... strings ){
System.out.println("calling main 1");
main();
}
}
It got compiled well, but while executing gave following error.
calling main 1
calling main 1
calling main 1
Exception in thread "main" java.lang.StackOverflowError
at sun.nio.cs.SingleByteEncoder.encodeArrayLoop(Unknown Source)
at sun.nio.cs.SingleByteEncoder.encodeLoop(Unknown Source)
at java.nio.charset.CharsetEncoder.encode(Unknown Source)
at sun.nio.cs.StreamEncoder.implWrite(Unknown Source)
at sun.nio.cs.StreamEncoder.write(Unknown Source)
at java.io.OutputStreamWriter.write(Unknown Source)
at java.io.BufferedWriter.flushBuffer(Unknown Source)
at java.io.PrintStream.write(Unknown Source)
at java.io.PrintStream.print(Unknown Source)
at java.io.PrintStream.println(Unknown Source)
at com.cm.portlet.trip.indent.action.Test.main(Test.java:7)
at com.cm.portlet.trip.indent.action.Test.main(Test.java:8)
at com.cm.portlet.trip.indent.action.Test.main(Test.java:8)
Since I have not defined any no-arg method for main(), I assume, it never tries to call main(). But why this was printing "calling main 1" ?
Can anyone let me understand this?
Regards
Suresh
[ August 22, 2008: Message edited by: suresh midde ]
When I tried to execute the following code, I got an error which is presented down.
public class Test {
public static void main(String... strings ){
System.out.println("calling main 1");
main();
}
}
It got compiled well, but while executing gave following error.
calling main 1
calling main 1
calling main 1
Exception in thread "main" java.lang.StackOverflowError
at sun.nio.cs.SingleByteEncoder.encodeArrayLoop(Unknown Source)
at sun.nio.cs.SingleByteEncoder.encodeLoop(Unknown Source)
at java.nio.charset.CharsetEncoder.encode(Unknown Source)
at sun.nio.cs.StreamEncoder.implWrite(Unknown Source)
at sun.nio.cs.StreamEncoder.write(Unknown Source)
at java.io.OutputStreamWriter.write(Unknown Source)
at java.io.BufferedWriter.flushBuffer(Unknown Source)
at java.io.PrintStream.write(Unknown Source)
at java.io.PrintStream.print(Unknown Source)
at java.io.PrintStream.println(Unknown Source)
at com.cm.portlet.trip.indent.action.Test.main(Test.java:7)
at com.cm.portlet.trip.indent.action.Test.main(Test.java:8)
at com.cm.portlet.trip.indent.action.Test.main(Test.java:8)
Since I have not defined any no-arg method for main(), I assume, it never tries to call main(). But why this was printing "calling main 1" ?
Can anyone let me understand this?
Regards
Suresh
[ August 22, 2008: Message edited by: suresh midde ]