Mastering Java and Spring Boot - Live Course : https://bit.ly/TeluskoJavaLive
For More Queries WhatsApp or Call on : +919008963671


In this lecture we will learn:
- forEach method in Java
- What is a consumer interface?
- Lambda expression with consumer object
- How forEach method works?


#1
- forEach method got introduced in Java 1.8 version.
- The forEach() method of ArrayList is used to perform a certain operation for each element in ArrayList.
- forEach traverses each element of the Iterable until all the elements have been processed.
- Collection classes that extend the Iterable interface can use forEach loop to iterate elements.

#2
- forEach method takes an object of the consumer.
- Consumer is an interface that belongs to the java.util.function package.
- Consumer is a functional interface so lambda expression will also be applicable to it.
- Consumer has a method accept(), that takes a value of the same type of which object is created.

- forEach needs an object and we will pass an object of a consumer in it.
- forEach gives a value at a time and that value gets passed to the consumer object and taken by the accept method.
- We can do operations in this accept method.

Github repo : https://github.com/navinreddy20/Javacode.git

Instagram : https://www.instagram.com/navinreddyofficial/
Linkedin : https://in.linkedin.com/in/navinreddy20
Discord : https://discord.gg/UrYda98D

Java:- https://bit.ly/JavaUdemyTelusko
Spring:- https://bit.ly/SpringUdemyTelusko

More Learning :

Java :- https://bit.ly/3x6rr0N
Python :- https://bit.ly/3GRc7JX
Django :- https://bit.ly/3MmoJK6

JavaScript :- https://bit.ly/3tiAlHo
Node JS :- https://bit.ly/3GT4liq

Rest Api :-https://bit.ly/3MjhZwt
Servlet :- https://bit.ly/3Q7eA7k
Spring Framework :- https://bit.ly/3xi7buh
Design Patterns in Java :- https://bit.ly/3MocXiq
Docker :- https://bit.ly/3xjWzLA

Blockchain Tutorial :- https://bit.ly/3NSbOkc
Corda Tutorial:- https://bit.ly/3thbUKa
Hyperledger Fabric :- https://bit.ly/38RZCRB

NoSQL Tutorial :- https://bit.ly/3aJpRuc
Mysql Tutorial :- https://bit.ly/3thpr4L

Data Structures using Java :- https://bit.ly/3MuJa7S
Git Tutorial :- https://bit.ly/3NXyCPu

Donation:
PayPal Id : navinreddy20
https://www.telusko.com