fork download
  1. import java.util.*;
  2. import java.lang.*;
  3.  
  4. class Main
  5. {
  6. public static void main (String[] args) throws java.lang.Exception
  7. {
  8. System.out.println("Start the test!");
  9. System.setErr(System.out);
  10. try
  11. { new Test(); } catch (Exception e) { e.printStackTrace(); }
  12.  
  13. try
  14. { new Test2(); } catch (Exception e) { e.printStackTrace(); }
  15.  
  16. try
  17. { new Test3(); } catch (Exception e) { e.printStackTrace(); }
  18.  
  19.  
  20. }
  21.  
  22. static class Test
  23. {
  24. Object obj = getObject();
  25. Object getObject()
  26. { throw new RuntimeException("getObject"); }
  27. }
  28.  
  29. static class Test2
  30. {
  31. Test2()
  32. {
  33. throw new RuntimeException("constructor");
  34. }
  35. }
  36.  
  37. static class Test3
  38. {
  39. Object obj1 = null;
  40. String str = obj1.toString();
  41. }
  42. }
Success #stdin #stdout 0.08s 380160KB
stdin
Standard input is empty
stdout
Start the test!
java.lang.RuntimeException: getObject
	at Main$Test.getObject(Main.java:26)
	at Main$Test.<init>(Main.java:24)
	at Main.main(Main.java:11)
java.lang.RuntimeException: constructor
	at Main$Test2.<init>(Main.java:33)
	at Main.main(Main.java:14)
java.lang.NullPointerException
	at Main$Test3.<init>(Main.java:40)
	at Main.main(Main.java:17)