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. interface ConsumerOne<T> {
  8. void accept(T a);
  9. }
  10.  
  11. interface CustomIterable<T> extends Iterable<T> {
  12. void forEach(ConsumerOne<? super T> c); //overload
  13. }
  14. class Ideone
  15. {
  16. private static CustomIterable<Ideone> iterable;
  17. private static List<Ideone> aList;
  18. public static void main (String[] args)
  19. {
  20. iterable.forEach((Ideone a) -> aList.add(a));
  21. }
  22. }
Compilation error #stdin compilation error #stdout 0s 0KB
stdin
Standard input is empty
compilation info
Main.java:20: error: reference to forEach is ambiguous
		iterable.forEach((Ideone a) -> aList.add(a));
		        ^
  both method forEach(Consumer<? super T#1>) in Iterable and method forEach(ConsumerOne<? super T#2>) in CustomIterable match
  where T#1,T#2 are type-variables:
    T#1 extends Object declared in interface Iterable
    T#2 extends Object declared in interface CustomIterable
1 error
stdout
Standard output is empty