Advertisement
Guest User

Untitled

a guest
Jun 26th, 2017
467
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.84 KB | None | 0 0
  1. ///////////////////////////////////////////////////////////////////////////////
  2. // StackOverflow.java
  3. // ==================
  4. // testing stack size of JVM
  5. //
  6. // AUTHOR: Song Ho Ahn (song.ahn@gmail.com)
  7. // CREATED: 2010-11-01
  8. // UPDATED: 2010-11-01
  9. ///////////////////////////////////////////////////////////////////////////////
  10.  
  11. public class StackOverflow // declare class
  12. {
  13.  
  14. public static int count = 0; // declare & initialize variable count
  15.  
  16.  
  17. public static void main(String[] args)
  18. {
  19. try
  20. {
  21. foo();
  22. }
  23.  
  24. catch(StackOverflowError e)
  25. {
  26. System.out.println("StackOverflowError at " + count);
  27. //e.printStackTrace();
  28. }
  29.  
  30. } // close main method
  31.  
  32. public static void foo() // create method foo()
  33. {
  34. ++count;
  35. foo();
  36. }
  37. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement