DEV Community

lou
lou

Posted on

Interface Consumer en Java bDarija

L'interface Consumer kaykon f java.util.function.

Syntax dialha:

@FunctionalInterface
public interface Consumer<T> {
  void accept(T t);
}
Enter fullscreen mode Exit fullscreen mode
  • T type de l'argument
  • t l'argument 
  • void type de retourne implique que la fonction makatrejee walo

Exemple dial program:

Consumer<Integer> consumer= new Consumer<Integer>() {
            @Override
            public void accept(Integer integer) {
                System.out.println(integer);
            }

        };
Enter fullscreen mode Exit fullscreen mode

nefs lcode walakin had lmera b lambda

Consumer<Integer> consumer1=(integer)-> System.out.println(integer);

Enter fullscreen mode Exit fullscreen mode

Top comments (0)