One additional note - although lambdas do only work in the context of a functional interface, you don't necessarily need to always create your own in order to use one. There are many that are built into Java, and they cover most uses cases you'll see: docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html
Good job , thank you for that !! Also I would love to see you making a video about streams and how we can associate the use of it with lambdas. Regards 👍🏻
The key point here like you say is lambdas allow method definitions to be used as variables/objects. Many other languages allow for function names to be passed as variables for callbacks and whatnot and Java never had a clean way to do that until lambdas. Only thing I would add to this is that putting the parameter type in the lambda expression is allowed and makes it easier to understand that the lambda is a method definition: (String p, String s) -> //code
Reflection allows that. And it exists since the very first versions of Java. It even does more than that. It allows you to break scope limitations and call a private/protected/package method from places that are not supposed to see the method. I used reflection once in my entire career. It was in java 1.2. And it was to access a method in a library that was erroneously declared as private by its author. At that time I didn't have access to a decompiler. Of course when I have a similar situation now, I simply decompile the class to create an override in my source code.
I wouldn't call that a clean way of doing it. You have to essentially create a type (functional interface) to which you then can dynamically assign an ad hoc implementation. In my mind, that's just a stupid way of doing it, compared to C or Javascript. What I would have done would be to introduce a parametrized type Function, that lets you create the declaration on the fly, like so: Function fancySquare = (String s, Number n) -> s + (n*n)
I am always impressed by how good you are at making yourself understandable, your explanations are all clear and meaningful. It's definitely a privilege being able to access such a high quality content for free.
I've been doing Java based web application development for over 20 years. I often like to take refresher courses on things I've studied before. This is easily the best explanation with practical examples I've seen for Java Lambas. The concepts are clearly explained. Thanks John for making such a great video!
You did in 5 minutes what my Uni prof. couldn't in two lectures. That goes to show how much people who actually use java professionally have a deeper understanding of java.
Hi, John, I'm not a quick learner, but I work hard. English is not my native language, and I watch and rewatch your videos a couple of times - and I can say: if you keep doing this amazing videos, I might learn some java. I'm reading a java handbook right now, but next, I'll take your course.
Head First Java book can be really helpful to you, it's really clear and easy to understand. It has translations to many languages too. You probably can find a PDF online. Use it as a complement to John's videos. Good luck!
I found Lambda Expression is the exact same Arrow Function in JavaScript. I think it's usable in terms of functional programming but don't know whether there is a need of it in object oriented language like Java! Thumbs up for you, indeed you are a great teacher.
Lambda is a shortcut to define an implementation of a functional interface. Instead of creating a class that implements that functional interface and adding an implementation that you want of that single abstract method, and create an object of this class, you simply create a lambda expression that contains the implementation of that functional interface method that you want. Man this summary clears out all my confusion about the significance of functional interface and lambda expression. Thank you soooo much for the clarification!!!
Java receives a lot of backlash from inexperienced and experienced developers of being too old school, bloated and lacking modern features and syntax, although.. ever since I have started watching your videos, I've seen a major improvement and they are really trying to keep things up to date as of lambda expressions which provide more of a functional approach towards problems. Turns out you just need a teacher like John to really appreciate and understand it. :)
Also this feature has existed for a long time, version 8 where it was introduced came out in 2014. Since then they greatly accelerated their version bump speed, currently we are at version 17 with a lot of new features like local type-inferred vars, switch lambdas, data records and so on.
I have been using lambdas for many years, first with Scala, then with Java, and watching your video, I am amazed how much I learned. Kudos to you for creating such as useful lesson...
Ever seen someone watching a tutorial even if he already knows the concept? well, that guy wasting time is me. I love the way he explains things. Keep it up, man.
I appreciate how your videos get straight to the point. I tried watching a video from another channel about a Java topic and at least half of the video could have been edited out with no loss of meaningful information.
Wow. This is the best explanation of lambdas I have come across. How you trim the expression in the beginning, removing access modifiers and so on is really great. Thank you!
That was extremely helpful in understanding what the heck is going on with the lambda syntax. I've seen them before but immediately understand it better after seeing him do that.
You are doing by far the best Explanations for Java and figuring out how to use all the Tools the Language gives you. Currently, struggling mighty with my Coding Exam in a couple of days, but you are saving my ass, so a Huge Thank You!
You are a very impressive tutor, you make the complex topics very simple and make the students understand the concepts step by step and that too in a very simplified manner with appropriate hands on coding examples. Thanks a lot for all your tech videos and everything you do.
I am a python engineer, not very proficient in java, but thanks to your course. Maybe sometimes your courses are simple, but they are still very helpful to me.
When I first started coding, I have used Java and these videos have been a great refresher on the smaller and intricate things that Java has to offer. Great videos! Already learned so many things.
OMG You are really really really a good teacher!!! I had got stuck of understanding the concept of Lambda for days till watching this video! Thanks a lot!!!
I have been working through a Java Udemy course, but it wasn't able to explain this subject to me. Watching your video is a relief! Now I understand! It's so much better.
It really feels good when understanding more about how it work when I literally use it everyday especially in java stream. The Best Explaination I can find in YT. Thanks alot
Thanks to your video, i could understand bascis of lambda. I could catch every info you provided, but couldn't understand from other sources. Thank you so much !
This was a big help! I've been programming in Java for 5 years, but used it like a traditional language and didn't use lambdas. They were always a big mystery to me. When I took a Java skill test there were a lot of lambda questions so that hurt me. This short course explained a lot.
Wow, i've never understand lambdas that well, but rn, i am happy that i can make my code workflow easier, and shorter! thank you for your great tutorial
Been a while i have done OOPS. Doing more of cloud coding in azure where we are using lambda expressions. Came back to check this out and i feel like goimg back to developer role. Thanks so much. You really made it as simple as you could
My java course teacher telling us how we shouldnt use youtube to learn Java, only his lectures. Yet he failed to explain a lot of concepts like lambda and here I learn them in 13 minutes
Great video as always Mr John, lambdas been a pain in the ass for a junior developer like for long long time and I do gotta say that I'm addicted to your videos as I learned better than in my school
Amazing explanation. When someone has the ability to explain such abstract example so smoothly that even the absolute begginer could understand it, that means that the person has huge knowledge about that matter. Thanx!
Oh yes, thank you so much for this video! I looked at many articles before etc. but couldn't really grip the entire thing or couldn't remember how to use them - now I can :)
This is a great explanation of Lambdas. Thank you, I have been a java dev for the last 9 years, I have never used functional interfaces or lambdas in a professional setting but I am getting ready for my OCA certification and this is an amazing explanation. This is the first time that someone has explained it in a way that made sense to me. I am most definitely going subbing to the channel.
couldn't understand from all the stack overflow explantion. drove me nuts. watch you video once and understood. This aitn the first time your videos do this I feel like everytime I watch your videos I only have to watch it once to get the picture lol..thank u john
thanks a lot. great: as you said "Lambda is a shortcut to defining an implementation of a functional interface", this sentence is all about lambda. thank you.
I am in my last semester as a cs major. You explain these concepts so well; maybe even better than my professors, and they are all really smart people!
This was an excellent video! I have struggled to understand lambdas for a while and you just connected all the pieces that reading documentation and running examples cannot. Thank you!
Hey Jhon, A humble request, can you please go in depth and explain the difference between Abstract Class and Interfaces. Which one to you use when, and why to even use 1 at the first place. Also, after the introduction of default,static and private also I guess. What exactly is the difference now.
Basically an abstact class is...well, a class, in this case, one that is designed to be inherited, you put the basic atributes, and then each subclass does extra stuff and maybe change's some basic atribute For example, Dog, ,whale,goat, Bat, Human and bear are all mammals, they all have hot blood, have some form of fur, and females feed their offspring milk, but the dog barks, the whaleives in the water, the goat climbs steep surfaces, the bear hibernates, the bat has a sonic radar and the human stands on two legs Meanwhile an interface can be considered either an addon or an common atribute between things that are not related or achieved in completely different ways For example, a bat, a hummingbird, a dragonfly a plane, hellicopter and a rocket all can fly, but do so in completely diferent ways, a bat's wings are just mutated giant hands that they still use grab things or themselves to surfaces, the hummingbirds have speciallized wings that allow tgem fine control of their angle and speed so they can hover, dragonflies have their four wings as extra appendages instead of being their "arms" , hellicoptets push air vertically to lift their weight while planes push it horizontally to gain speed and they win height by shanging the air pressure between the higher and lower parts with the dessign of the wings, an finally a rocket is basically a controlled explossion
Mechanically speaking, the biggest differences between interfaces with default methods and abstract classes is that abstract classes can declare visibility other than public (e.g. protected abstract methods are a common pattern), and they can have state (variables) of their own. For example, AbstractCollection could be turned into an interface with default methods just fine. As it only has methods, no state (and frankly I'm a bit disappointed they didn't just fold it into the Collection interface). However, AbstractList could _not_ be. As it has a protected method (removeRange) and internal state (the number of modification tracking thing)
You explained so well, to this time I was not able to understand anything related to lambdas and functional interfaces, but your video opened my eyes! new Subscriber and will check all of your courses right now!
Thanks a lot mate! I knew those things you were talking about. Just watched to see if you explain properly, and I can surely say that it was perfect. I will watch other tutorials you posted to learn even more.
Let me say that in my own words: a lambda is an implementation of the only abstract method on a functional interface. With this, we avoid building a class that implements that interface and the objects associated with it. OMG! Thank you for explaining how that works behind the scenes.
I have been watching your videos for a while and I have to say you are an excellent resource. You explain in such an intuitive way. Now when I don't understand a concept, I check if you have done a video on it first. Thanks for all you do!
Hi John, Thanks a lot for your commitment, by watching your videos every day I learned so much about Java. one of the best way thad happened to me during my Java learning journey was finding your channel. 😃😃
One additional note - although lambdas do only work in the context of a functional interface, you don't necessarily need to always create your own in order to use one. There are many that are built into Java, and they cover most uses cases you'll see:
docs.oracle.com/javase/8/docs/api/java/util/function/package-summary.html
I swear John you must be going to my university with me or something this is the exact thing I needed thank you!
Thanks for this
Great, I was looking for this, thank you!
Good job , thank you for that !! Also I would love to see you making a video about streams and how we can associate the use of it with lambdas.
Regards 👍🏻
Please do Java Reflection, if there is a person who can do it well, it would be you
The key point here like you say is lambdas allow method definitions to be used as variables/objects. Many other languages allow for function names to be passed as variables for callbacks and whatnot and Java never had a clean way to do that until lambdas. Only thing I would add to this is that putting the parameter type in the lambda expression is allowed and makes it easier to understand that the lambda is a method definition: (String p, String s) -> //code
thanks, bc i was wondering what was the point of all this, it didn't look like a step forward at first, it looked like a step backwards
It works like JS callback/anonymous function. The method definition: (String p, String s) -> {}; is indeed a caveat
Reflection allows that. And it exists since the very first versions of Java.
It even does more than that. It allows you to break scope limitations and call a private/protected/package method from places that are not supposed to see the method.
I used reflection once in my entire career. It was in java 1.2. And it was to access a method in a library that was erroneously declared as private by its author. At that time I didn't have access to a decompiler. Of course when I have a similar situation now, I simply decompile the class to create an override in my source code.
I wouldn't call that a clean way of doing it. You have to essentially create a type (functional interface) to which you then can dynamically assign an ad hoc implementation. In my mind, that's just a stupid way of doing it, compared to C or Javascript. What I would have done would be to introduce a parametrized type Function, that lets you create the declaration on the fly, like so: Function fancySquare = (String s, Number n) -> s + (n*n)
@@feynthefallencan't you just create that parameterized type yourself? The current implementation gives more flexibility.
My biggest "a-ha" moment here was when you showed how we go from public void print() {} to just () -> {}. Super intuitive, very good work!
I am always impressed by how good you are at making yourself understandable, your explanations are all clear and meaningful. It's definitely a privilege being able to access such a high quality content for free.
Yes
Oh yeah!!!😀
I've been doing Java based web application development for over 20 years. I often like to take refresher courses on things I've studied before. This is easily the best explanation with practical examples I've seen for Java Lambas. The concepts are clearly explained. Thanks John for making such a great video!
You did in 5 minutes what my Uni prof. couldn't in two lectures. That goes to show how much people who actually use java professionally have a deeper understanding of java.
Hi, John,
I'm not a quick learner, but I work hard.
English is not my native language, and I watch and rewatch your videos a couple of times - and I can say: if you keep doing this amazing videos, I might learn some java.
I'm reading a java handbook right now, but next, I'll take your course.
Head First Java book can be really helpful to you, it's really clear and easy to understand. It has translations to many languages too. You probably can find a PDF online. Use it as a complement to John's videos. Good luck!
You should start right now too
Please don't ever stop uploading. These videos help me in my academics and coding in general a lot. Thank You.
I found Lambda Expression is the exact same Arrow Function in JavaScript. I think it's usable in terms of functional programming but don't know whether there is a need of it in object oriented language like Java!
Thumbs up for you, indeed you are a great teacher.
Lambda is a shortcut to define an implementation of a functional interface. Instead of creating a class that implements that functional interface and adding an implementation that you want of that single abstract method, and create an object of this class, you simply create a lambda expression that contains the implementation of that functional interface method that you want. Man this summary clears out all my confusion about the significance of functional interface and lambda expression. Thank you soooo much for the clarification!!!
Java receives a lot of backlash from inexperienced and experienced developers of being too old school, bloated and lacking modern features and syntax, although.. ever since I have started watching your videos, I've seen a major improvement and they are really trying to keep things up to date as of lambda expressions which provide more of a functional approach towards problems.
Turns out you just need a teacher like John to really appreciate and understand it. :)
Also this feature has existed for a long time, version 8 where it was introduced came out in 2014. Since then they greatly accelerated their version bump speed, currently we are at version 17 with a lot of new features like local type-inferred vars, switch lambdas, data records and so on.
I have never seen anyone who can explain lambas expression as good as your. You help a lot for ppl who doesnt lambas.
I have been using lambdas for many years, first with Scala, then with Java, and watching your video, I am amazed how much I learned. Kudos to you for creating such as useful lesson...
one of the best, succinct yet comprehensive overviews of lambdas in java that i've ever come across! thanks a lot
I had to watch dozens of videos to understand lambda expressions. Finally i found the right one. Thanks a ton 🙏
With more than 20 years experience in Java programming, you really explain advanced topics so simple!!
Ever seen someone watching a tutorial even if he already knows the concept? well, that guy wasting time is me. I love the way he explains things. Keep it up, man.
lol. me too!
I appreciate how your videos get straight to the point. I tried watching a video from another channel about a Java topic and at least half of the video could have been edited out with no loss of meaningful information.
I've been using lambda for a while but it's the first time I understand how it works behind the scenes, thanks a lot for this video!
Wow. This is the best explanation of lambdas I have come across. How you trim the expression in the beginning, removing access modifiers and so on is really great. Thank you!
That was extremely helpful in understanding what the heck is going on with the lambda syntax. I've seen them before but immediately understand it better after seeing him do that.
This was by far the best explanation for lambda. PERIOD
You are doing by far the best Explanations for Java and figuring out how to use all the Tools the Language gives you. Currently, struggling mighty with my Coding Exam in a couple of days, but you are saving my ass, so a Huge Thank You!
You are a very impressive tutor, you make the complex topics very simple and make the students understand the concepts step by step and that too in a very simplified manner with appropriate hands on coding examples. Thanks a lot for all your tech videos and everything you do.
I must say you are one of the greatest coding teachers I have ever seen! Thanks John!
I am a python engineer, not very proficient in java, but thanks to your course. Maybe sometimes your courses are simple, but they are still very helpful to me.
This course is a gem, concise, clear and thorough, thank you!
Took this 13 minute video over my 2 hour lecture and i can proudly say i understand it better and didnt ever fell asleep in btw
You are a phenomenal instructor - you saved my behind in data structures and algorithms and this was a great refresher on lambdas.
When I first started coding, I have used Java and these videos have been a great refresher on the smaller and intricate things that Java has to offer. Great videos! Already learned so many things.
OMG You are really really really a good teacher!!!
I had got stuck of understanding the concept of Lambda for days till watching this video!
Thanks a lot!!!
Finally a human explanation ! Thank you so much !
Never came across a more clearer explanation!
I am really impressed by how good you explain each method. THANK YOU
I have been working through a Java Udemy course, but it wasn't able to explain this subject to me. Watching your video is a relief! Now I understand! It's so much better.
It really feels good when understanding more about how it work when I literally use it everyday especially in java stream. The Best Explaination I can find in YT. Thanks alot
Thanks to your video, i could understand bascis of lambda. I could catch every info you provided, but couldn't understand from other sources.
Thank you so much !
Absoultly clear and concise! Thanks alot!
This was a big help! I've been programming in Java for 5 years, but used it like a traditional language and didn't use lambdas. They were always a big mystery to me. When I took a Java skill test there were a lot of lambda questions so that hurt me. This short course explained a lot.
Wow, i've never understand lambdas that well, but rn, i am happy that i can make my code workflow easier, and shorter! thank you for your great tutorial
The quality of this channel, no word.
one of the best videos on Lamda
Short and to the point
Thanks @CodingWithJohn
Amazing video. Clear and precise. Thanks for that
I am studying cs in university and we had an oop course in java this semester... Thank you very much ! :)
John ! I want you to know that you're the coolest Java teacher. I injoyed your courses a lot , so THANK YOU !!
The best explanation i heard until now
Been a while i have done OOPS. Doing more of cloud coding in azure where we are using lambda expressions. Came back to check this out and i feel like goimg back to developer role. Thanks so much. You really made it as simple as you could
The best lambda explanation ever. Thank you!
John hats off to your simplicity explanation. You have excellent command in your communication. 👏
My java course teacher telling us how we shouldnt use youtube to learn Java, only his lectures. Yet he failed to explain a lot of concepts like lambda and here I learn them in 13 minutes
Oh thanks, i'm starting with lambda and this video was perfect. You are amazing.
Great video as always Mr John, lambdas been a pain in the ass for a junior developer like for long long time and I do gotta say that I'm addicted to your videos as I learned better than in my school
Amazing explanation. When someone has the ability to explain such abstract example so smoothly that even the absolute begginer could understand it, that means that the person has huge knowledge about that matter. Thanx!
The best explanation of lambdas! Thank you so much🙏
Thank you now i finally understood how lambda works.
I discovered this channel today and already watched about 7 videos. Amazing! Thanks
Спасибо большое из Беларуси! (Thanks a lot from Belarus)
Huge THANK YOU from Ukrainian developer!
/
Велике дякую Вам від українського розробника!
This channel is a goldmine
in awe of the quality.
Clear, concise and to the point. Nice video John.
Oh yes, thank you so much for this video! I looked at many articles before etc. but couldn't really grip the entire thing or couldn't remember how to use them - now I can :)
This is a great explanation of Lambdas. Thank you, I have been a java dev for the last 9 years, I have never used functional interfaces or lambdas in a professional setting but I am getting ready for my OCA certification and this is an amazing explanation. This is the first time that someone has explained it in a way that made sense to me. I am most definitely going subbing to the channel.
Listen bro, this is the best explanation of Lambda's I've seen on TH-cam. Great job. I just subscribed.
couldn't understand from all the stack overflow explantion. drove me nuts. watch you video once and understood. This aitn the first time your videos do this I feel like everytime I watch your videos I only have to watch it once to get the picture lol..thank u john
thanks a lot. great: as you said "Lambda is a shortcut to defining an implementation of a functional interface", this sentence is all about lambda. thank you.
Which can be implemented as a static method. Lambdas are just a way to write unnamed functions and make debugging harder.
Thank you for this tutorial! Now, I understand lambda in Java.
Never have seen a so clearly explanation about java lambdas. You rock!
not bad quick and insightful, defiantly helps with the lambdas section on headfirst java
Very clean explanation !! Thanks @Coding With John.
I am in my last semester as a cs major. You explain these concepts so well; maybe even better than my professors, and they are all really smart people!
This was an excellent video! I have struggled to understand lambdas for a while and you just connected all the pieces that reading documentation and running examples cannot. Thank you!
Hi John. Your videos are making me consider use java again in my projects
Hey Jhon,
A humble request, can you please go in depth and explain the difference between Abstract Class and Interfaces.
Which one to you use when, and why to even use 1 at the first place.
Also, after the introduction of default,static and private also I guess.
What exactly is the difference now.
Basically an abstact class is...well, a class, in this case, one that is designed to be inherited, you put the basic atributes, and then each subclass does extra stuff and maybe change's some basic atribute
For example, Dog, ,whale,goat, Bat, Human and bear are all mammals, they all have hot blood, have some form of fur, and females feed their offspring milk, but the dog barks, the whaleives in the water, the goat climbs steep surfaces, the bear hibernates, the bat has a sonic radar and the human stands on two legs
Meanwhile an interface can be considered either an addon or an common atribute between things that are not related or achieved in completely different ways
For example, a bat, a hummingbird, a dragonfly a plane, hellicopter and a rocket all can fly, but do so in completely diferent ways, a bat's wings are just mutated giant hands that they still use grab things or themselves to surfaces, the hummingbirds have speciallized wings that allow tgem fine control of their angle and speed so they can hover, dragonflies have their four wings as extra appendages instead of being their "arms" , hellicoptets push air vertically to lift their weight while planes push it horizontally to gain speed and they win height by shanging the air pressure between the higher and lower parts with the dessign of the wings, an finally a rocket is basically a controlled explossion
Mechanically speaking, the biggest differences between interfaces with default methods and abstract classes is that abstract classes can declare visibility other than public (e.g. protected abstract methods are a common pattern), and they can have state (variables) of their own.
For example, AbstractCollection could be turned into an interface with default methods just fine. As it only has methods, no state (and frankly I'm a bit disappointed they didn't just fold it into the Collection interface).
However, AbstractList could _not_ be. As it has a protected method (removeRange) and internal state (the number of modification tracking thing)
Finally I understood this lambda expression thing. I came form JavaScript and Java's Lamda Expression is so confusing.
You explained so well, to this time I was not able to understand anything related to lambdas and functional interfaces, but your video opened my eyes! new Subscriber and will check all of your courses right now!
Thanks a lot mate! I knew those things you were talking about. Just watched to see if you explain properly, and I can surely say that it was perfect. I will watch other tutorials you posted to learn even more.
Just blow my mind. Finally can understand the sintax behind the lambda
After watching so many videos, its first time I'm feeling that it's the best explanation 👍
Good man....explained with confidence and clear
Again! my subscription to your channel is never a waste. God you are such a good teacher!! Thank you again for this 💃💃💃
This tutorial was concise and precise, thank you for such a clear explanation!!!
Waiting for this topic for a long time, and it has been delivered more than enough. Thanks John so much
+1, he's totally nailed it once again
Clear, concise, to the point, thanks a lot !! Helped a lot
Most wanted tutorial from you!!! Thanks :)
best programming teacher
The syntactic and semantic beauty of functions always and only ABSTRACTING OVER EXPRESSIONS! Wicked... (:-)
Lambdas allow you "to effectively treat code as a parameter". Thank you!
Awesome. Now not only JavaScript has arrow functions, but also Java. It's lovely for someone working on web development as well.
Excellent explanation on Lamdas.
My English level a2-b1 but l enjoy watching your videos 😊 Thank you for your hard work.
Thank you so much for the explanation! This is the best video on lambda topic that I ever seen. It is very clear and straightforward.
I love how you explain concepts
Now this makes perfect background for "Streams", please make a video on that also. 🙂
excellent explanation of Java. Thanks John for the amazing tutorials.
Let me say that in my own words: a lambda is an implementation of the only abstract method on a functional interface. With this, we avoid building a class that implements that interface and the objects associated with it. OMG! Thank you for explaining how that works behind the scenes.
Thanks! Best exlanation of lambda funvtions.
I have been watching your videos for a while and I have to say you are an excellent resource. You explain in such an intuitive way. Now when I don't understand a concept, I check if you have done a video on it first. Thanks for all you do!
Hi John,
Thanks a lot for your commitment,
by watching your videos every day I learned so much about Java.
one of the best way thad happened to me during my Java learning journey
was finding your channel. 😃😃
Thanks, man it's very helpful explanation of this topic. I needed help with return type lambda implementation.
This simple and best video to understand lambda. Good one John.