fork(2) download
  1. public final class Main {
  2.  
  3. public static void main (String[] args) {
  4. var yellow = Color.findByName("YELLOW");
  5. // Since 'yellow' can be null, the next statement may throw a
  6. // NullPointerException.
  7. var rgb = yellow.getRgb();
  8. }
  9.  
  10. public interface Color {
  11.  
  12. /**
  13. Returns the Color instance that matches with the specified name.
  14.  
  15.   @param name
  16.   ...
  17.   @return
  18. {@code null} if nothing matches with {@code name}.
  19. Otherwise, the instance that matches.
  20.   */
  21. static Color findByName(String name) {
  22. return null;
  23. }
  24.  
  25. /**
  26. Returns the 24-bit integer value representing RGB.
  27.  
  28.   @return
  29.   ...
  30.   */
  31. int getRgb();
  32. }
  33. }
  34.  
Runtime error #stdin #stdout #stderr 0.06s 32572KB
stdin
Standard input is empty
stdout
Standard output is empty
stderr
Exception in thread "main" java.lang.NullPointerException
	at Main.main(Main.java:7)