Skip to content

Commit 16c73dc

Browse files
committed
Add introduction of cosumer functional interface and it's methods
1 parent 5ba3977 commit 16c73dc

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

README.md

+14
Original file line numberDiff line numberDiff line change
@@ -40,3 +40,17 @@ By using @FunctionalInterface annotation
4040
3. Implementation of method must be static
4141

4242

43+
#### There are few functional interfaces namely Consumer, Supplier, Predicate provided by Java 8.
44+
45+
### Consumer
46+
47+
- A Consumer is a functional interface that accepts a single input and returns no output.
48+
- Consumer interface has two methods:
49+
50+
```
51+
void accept(T t);
52+
default Consumer<T> andThen(Consumer<? super T> after);
53+
```
54+
- The ```accept``` method is the Single Abstract Method (SAM) which accepts a single argument of type T.
55+
- ```andThen``` is a default method used for composition.
56+

0 commit comments

Comments
 (0)