fork download
  1. import java.io.IOException;
  2.  
  3. class Ideone {
  4. private static <T extends Throwable> void rethrow(Throwable t) throws T {
  5. throw (T) t;
  6. }
  7.  
  8. private static void withoutExceptionsDeclaration() {
  9. try {
  10. throw new IOException();
  11. } catch (Throwable t) {
  12. rethrow(t);
  13. }
  14. }
  15.  
  16. private static void test() throws IOException {
  17. throw new IOException();
  18. }
  19.  
  20. public static void main (String[] args) {
  21. withoutExceptionsDeclaration();
  22. }
  23. }
Runtime error #stdin #stdout #stderr 0.06s 32480KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.io.IOException
	at Ideone.withoutExceptionsDeclaration(Main.java:10)
	at Ideone.main(Main.java:21)