Skip to main content
replaced http://stackoverflow.com/ with https://stackoverflow.com/
Source Link

Java

class Gotcha { public static void main(String... args) { try { main(); } finally { main(); } } } 

No stack overflows here; move along.

At first glance, this should produce a StackOverflowError, but it doesn't! It actually just runs forever (for all practical purposes at least; technically it would terminate after a time many orders of magnitude longer than the age of the universe). If you want to know how/why this works, see thisthis. Also, if you happen to be wondering why we can call main() without arguments when the main method generally would need a String[] argument: it's because we've declared it to be variable-argument here, which is perfectly valid.

Java

class Gotcha { public static void main(String... args) { try { main(); } finally { main(); } } } 

No stack overflows here; move along.

At first glance, this should produce a StackOverflowError, but it doesn't! It actually just runs forever (for all practical purposes at least; technically it would terminate after a time many orders of magnitude longer than the age of the universe). If you want to know how/why this works, see this. Also, if you happen to be wondering why we can call main() without arguments when the main method generally would need a String[] argument: it's because we've declared it to be variable-argument here, which is perfectly valid.

Java

class Gotcha { public static void main(String... args) { try { main(); } finally { main(); } } } 

No stack overflows here; move along.

At first glance, this should produce a StackOverflowError, but it doesn't! It actually just runs forever (for all practical purposes at least; technically it would terminate after a time many orders of magnitude longer than the age of the universe). If you want to know how/why this works, see this. Also, if you happen to be wondering why we can call main() without arguments when the main method generally would need a String[] argument: it's because we've declared it to be variable-argument here, which is perfectly valid.

added 25 characters in body
Source Link
arshajii
  • 2.2k
  • 12
  • 21

Java

class Gotcha { public static void main(String... args) { try { main(); } finally { main(); } } } 

No stack overflows here; move along.

At first glance, this should produce a StackOverflowError, but it doesn't! It actually just runs forever (for all practical purposes at least; technically it would terminate after a time many orders of magnitude longer than the age of the universe). If you want to know how/why this works, see this. Also, if you happen to be wondering why we can call main() without arguments when the main method generally would need a String[] argument: it's because we've declared it to be variable-argument here, which is perfectly valid.

Java

class Gotcha { public static void main(String... args) { try { main(); } finally { main(); } } } 

No stack overflows here; move along.

At first glance, this should produce a StackOverflowError, but it doesn't! It actually just runs forever (for all practical purposes at least; technically it would terminate after a time longer than the age of the universe). If you want to know how/why this works, see this. Also, if you happen to be wondering why we can call main() without arguments when the main method generally would need a String[] argument: it's because we've declared it to be variable-argument here, which is perfectly valid.

Java

class Gotcha { public static void main(String... args) { try { main(); } finally { main(); } } } 

No stack overflows here; move along.

At first glance, this should produce a StackOverflowError, but it doesn't! It actually just runs forever (for all practical purposes at least; technically it would terminate after a time many orders of magnitude longer than the age of the universe). If you want to know how/why this works, see this. Also, if you happen to be wondering why we can call main() without arguments when the main method generally would need a String[] argument: it's because we've declared it to be variable-argument here, which is perfectly valid.

added 114 characters in body
Source Link
arshajii
  • 2.2k
  • 12
  • 21

Java

class Gotcha { public static void main(String... args) { try { main(); } finally { main(); } } } 

No stack overflows here; move along.

At first glance, this should produce a StackOverflowError --, but it doesn't! It actually just runs forever (for all practical purposes at least; technically it would terminate after a time longer than the age of the universe). If you want to know how/why this works, see this. Also, if you happen to be wondering why we can call main() without arguments when the main method generally would need a String[] argument: it's because we've declared it to be variable-argument here, which is perfectly valid.

Java

class Gotcha { public static void main(String... args) { try { main(); } finally { main(); } } } 

No stack overflows here; move along.

At first glance, this should produce a StackOverflowError -- but it doesn't! It actually just runs forever. If you want to know how/why this works, see this. Also, if you happen to be wondering why we can call main() without arguments when the main method generally would need a String[] argument: it's because we've declared it to be variable-argument here, which is perfectly valid.

Java

class Gotcha { public static void main(String... args) { try { main(); } finally { main(); } } } 

No stack overflows here; move along.

At first glance, this should produce a StackOverflowError, but it doesn't! It actually just runs forever (for all practical purposes at least; technically it would terminate after a time longer than the age of the universe). If you want to know how/why this works, see this. Also, if you happen to be wondering why we can call main() without arguments when the main method generally would need a String[] argument: it's because we've declared it to be variable-argument here, which is perfectly valid.

added 37 characters in body
Source Link
arshajii
  • 2.2k
  • 12
  • 21
Loading
added 18 characters in body
Source Link
arshajii
  • 2.2k
  • 12
  • 21
Loading
added 214 characters in body
Source Link
arshajii
  • 2.2k
  • 12
  • 21
Loading
Source Link
arshajii
  • 2.2k
  • 12
  • 21
Loading