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 void close(){
  18. System.out.println("Closing");
  19. throw new RuntimeException("Closing failed");
  20. }
  21. }
Runtime error #stdin #stdout #stderr 0.08s 32520KB
stdin
Standard input is empty
stdout
Trying
Closing
stderr
Exception in thread "main" java.lang.RuntimeException: Trying failed
	at Ideone.main(Main.java:11)
	Suppressed: java.lang.RuntimeException: Closing failed
		at Resource.close(Main.java:19)
		at Ideone.main(Main.java:9)