fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6.  
  7. class Option<T> {
  8. private T o;
  9.  
  10. Option() {
  11. this(null);
  12. }
  13.  
  14. Option(T o) {
  15. this.o = o;
  16. }
  17.  
  18. T some() throws Exception {
  19. if (o == null) throw new Exception("A vot hui");
  20. return o;
  21. }
  22. }
  23.  
  24. class ItDoesntHandleException {
  25. ItDoesntHandleException(Option o) {
  26. System.out.println(o.some());
  27. }
  28. }
  29.  
  30. /* Name of the class has to be "Main" only if the class is public. */
  31. class Ideone
  32. {
  33. public static void main (String[] args) throws java.lang.Exception
  34. {
  35. Option<Number> o = new Option();
  36. System.out.println(o.some());
  37. new ItDoesntHandleException(o);
  38. }
  39. }
  40.  
  41.  
Compilation error #stdin compilation error #stdout 0.04s 2184192KB
stdin
Standard input is empty
compilation info
Main.java:26: error: unreported exception Exception; must be caught or declared to be thrown
		System.out.println(o.some());	
		                         ^
Note: Main.java uses unchecked or unsafe operations.
Note: Recompile with -Xlint:unchecked for details.
1 error
stdout
Standard output is empty