fork download
  1. /* package whatever; // don't place package name! */
  2.  
  3. import java.util.*;
  4. import java.lang.*;
  5. import java.io.*;
  6. import java.util.Optional;
  7. import java.util.function.Consumer;
  8.  
  9. /* Name of the class has to be "Main" only if the class is public. */
  10. class A {
  11. private void setter(final Number value) { }
  12. private <T> void setter(final Optional<? super T> value) { }
  13. private void setter2(final Optional<Number> value) { }
  14.  
  15. private <T> void useSetter(final Consumer<Optional<T>> a) { }
  16.  
  17. private void callMethod() {
  18. useSetter(this::setter); // Error here
  19. useSetter(this::setter2);
  20. }
  21.  
  22. public static void main(String [] args){
  23.  
  24. }
  25. }
  26.  
  27. class B {
  28. private void setter(final Number value) { }
  29. private void setter(final Optional<? super Number> value) { }
  30. private void setter2(final Optional<Number> value) { }
  31.  
  32. private <T> void useSetter(final Consumer<Optional<T>> a) { }
  33.  
  34. private void callMethod() {
  35. useSetter(this::setter); // Error here
  36. useSetter(this::setter2);
  37. }
  38.  
  39. public static void main(String [] args){
  40.  
  41. }
  42. }
Success #stdin #stdout 0.04s 4386816KB
stdin
Standard input is empty
stdout
Standard output is empty