#74 Lambda Expression with return

preview_player
Показать описание
Check out our courses:

Coupon: TELUSKO10 (10% Discount)

Coupon: TELUSKO20 (20% Discount)

Udemy Courses:

For More Queries WhatsApp or Call on : +919008963671

In this lecture we are discussing about lambda expression:

#1
-- if we have a functional interface
interface A{
int add(int i, int j);
}
in this case, we return int type from add a method for that we can write a lambda expression
in different ways.
-- if we have a single statement you do not need of curly braces
A obj1 =(i,j)- return i+j;

-- if we want to return something in a single statement, no need to mention the return keyword
A obj2 =(i,j)-i+j;

#2
Example:
class Main{
public static void main(String[] args){
// Anonymous class with lambda expression
//if you have single statement and want to return something then you need not to write return keyword and curly braces
A obj= (i,j)- i+j;
//lambada expression works with functional interface
}
}

interface A{
public int add(int i,int j);
}

More Learning :

Donation:
PayPal Id : navinreddy20
Рекомендации по теме
Комментарии
Автор

Whatever doubt I do have are always cleared while going through your videos. Précised & image driven explanations are helpful to underst6and the back end logics. Thank you for making the videos informative in interesting way.

papiyadebbarman
Автор

Awesome explanation! Thank you very much for this course.

sammclaren
Автор

Ur videos are gold. Keep up the good work!

tarrincurtis
Автор

Just after watching your some Java videos I became your fan. You teach so well that it become easy to understand. If you got time please make a video playlist on Android Development using Java. Thank you 🤗

sakibul_alam
Автор

user understand way of explanation is going on your channel ....thank you

byrimahesh
Автор

What if i have a default method inside functional interface and i need to call that default method. How will we do that if we are using lambda expression?

nikhiljose
Автор

[Be an efficient programmer] i like it

Aviation
Автор

I used lamda with two anonymous inner class

By making two variables in interface,
Then making 2 obj of reference A in main method

A obj1 =
A obj2 =

It worked without functional interface?

shaad
Автор

In java 20 a new feature will be introduced, users can write .class files directly to make things simpler and save space..😂 i think these kind of syntaxes will only create headache and affect code readability..

Akshay-ojoc
Автор

Please add more videos lambda expression Steam API with collection

dollytiwari