fork download
  1. import java.util.*;
  2. import java.lang.*;
  3. import java.io.*;
  4.  
  5. class Ideone
  6. {
  7. public static void main (String[] args) throws java.lang.Exception
  8. {
  9. try(Resource resource = new Resource()){
  10. System.out.println("Trying");
  11. throw new RuntimeException("Trying failed");
  12. }
  13. }
  14. }
  15.  
  16. class Resource implements Closeable {
  17. public Resource(){
  18. System.out.println("Resource");
  19. throw new RuntimeException("Resource failed");
  20. }
  21.  
  22. public void close(){
  23. System.out.println("Closing");
  24. throw new RuntimeException("Closing failed");
  25. }
  26. }
Runtime error #stdin #stdout #stderr 0.06s 32472KB
stdin
Standard input is empty
stdout
Resource
stderr
Exception in thread "main" java.lang.RuntimeException: Resource failed
	at Resource.<init>(Main.java:19)
	at Ideone.main(Main.java:9)