fork(1) download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. /* Name of the class has to be "Main" only if the class is public. */
  8. class Ideone
  9. {
  10. private static class CustomException extends Exception {
  11. }
  12. public static void main (String[] args) throws java.lang.Exception
  13. {
  14. try
  15. {
  16. System.out.println("Calling nocatch(false)");
  17. nocatch(false);
  18. }
  19. catch (CustomException ce) {
  20. System.out.println("Caught CustomException for false case");
  21. }
  22. try
  23. {
  24. System.out.println("Calling nocatch(true)");
  25. nocatch(true);
  26. }
  27. catch (CustomException ce) {
  28. System.out.println("Caught CustomException for true case");
  29. }
  30. }
  31.  
  32. public static void nocatch(boolean foo) throws CustomException
  33. {
  34. try
  35. {
  36. if (foo) {
  37. System.out.println("Throwing");
  38. throw new CustomException();
  39. }
  40. }
  41. finally
  42. {
  43. System.out.println("In finally");
  44. }
  45. System.out.println("Reached outside the try/finally block");
  46. }
  47. }
Success #stdin #stdout 0.1s 320320KB
stdin
Standard input is empty
stdout
Calling nocatch(false)
In finally
Reached outside the try/finally block
Calling nocatch(true)
Throwing
In finally
Caught CustomException for true case