Lambda Expressions in Java - Full Simple Tutorial

  Рет қаралды 769,687

Coding with John

Coding with John

Күн бұрын

Пікірлер: 632
@CodingWithJohn
@CodingWithJohn 2 жыл бұрын
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
@rokitap.w1193
@rokitap.w1193 2 жыл бұрын
I swear John you must be going to my university with me or something this is the exact thing I needed thank you!
@libertymedicalcommunicatio4908
@libertymedicalcommunicatio4908 2 жыл бұрын
Thanks for this
@Hufsa
@Hufsa 2 жыл бұрын
Great, I was looking for this, thank you!
@yasseromari1074
@yasseromari1074 2 жыл бұрын
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 👍🏻
@babythedude
@babythedude 2 жыл бұрын
Please do Java Reflection, if there is a person who can do it well, it would be you
@danielcommins1285
@danielcommins1285 2 жыл бұрын
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
@stepbystepcoding4113
@stepbystepcoding4113 2 жыл бұрын
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
@enfieldli9296
@enfieldli9296 2 жыл бұрын
It works like JS callback/anonymous function. The method definition: (String p, String s) -> {}; is indeed a caveat
@christianbarnay2499
@christianbarnay2499 9 ай бұрын
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.
@feynthefallen
@feynthefallen 9 ай бұрын
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)
@danielcommins1285
@danielcommins1285 8 ай бұрын
​@@feynthefallencan't you just create that parameterized type yourself? The current implementation gives more flexibility.
@djk1288
@djk1288 Жыл бұрын
My biggest "a-ha" moment here was when you showed how we go from public void print() {} to just () -> {}. Super intuitive, very good work!
@felipe2637
@felipe2637 2 жыл бұрын
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.
@gatescob
@gatescob Жыл бұрын
Yes
@ntigirishari
@ntigirishari Жыл бұрын
Oh yeah!!!😀
@carlellis9647
@carlellis9647 2 жыл бұрын
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!
@zipkitty
@zipkitty Жыл бұрын
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.
@andersonabe5044
@andersonabe5044 2 жыл бұрын
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.
@fabiorachid3430
@fabiorachid3430 2 жыл бұрын
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!
@emmanuelnsiah8036
@emmanuelnsiah8036 Жыл бұрын
You should start right now too
@xsraut
@xsraut 2 жыл бұрын
Please don't ever stop uploading. These videos help me in my academics and coding in general a lot. Thank You.
@robertzaryal3416
@robertzaryal3416 2 жыл бұрын
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.
@jonathanchiii1706
@jonathanchiii1706 2 жыл бұрын
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!!!
@raz0229
@raz0229 2 жыл бұрын
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. :)
@Quinteger
@Quinteger 2 жыл бұрын
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.
@dangnguyen.92
@dangnguyen.92 2 жыл бұрын
I have never seen anyone who can explain lambas expression as good as your. You help a lot for ppl who doesnt lambas.
@EricKolotyluk
@EricKolotyluk 2 жыл бұрын
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...
@AmanRaj-dh2ru
@AmanRaj-dh2ru 5 ай бұрын
one of the best, succinct yet comprehensive overviews of lambdas in java that i've ever come across! thanks a lot
@prathap2712
@prathap2712 Жыл бұрын
I had to watch dozens of videos to understand lambda expressions. Finally i found the right one. Thanks a ton 🙏
@hmzza1
@hmzza1 2 жыл бұрын
With more than 20 years experience in Java programming, you really explain advanced topics so simple!!
@raymondorenda7385
@raymondorenda7385 Жыл бұрын
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.
@stephanieezat-panah7750
@stephanieezat-panah7750 9 ай бұрын
lol. me too!
@cavendar24
@cavendar24 Жыл бұрын
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.
@MaryamMaqdisi
@MaryamMaqdisi 2 жыл бұрын
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!
@twisterwiper
@twisterwiper 2 жыл бұрын
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!
@burgerbob7324
@burgerbob7324 2 жыл бұрын
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.
@ShubhamSingh-vh1vw
@ShubhamSingh-vh1vw Жыл бұрын
This was by far the best explanation for lambda. PERIOD
@assur7477
@assur7477 4 ай бұрын
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!
@JayantBhalerao-lf9wj
@JayantBhalerao-lf9wj 5 ай бұрын
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.
@juanestebanparraparra8531
@juanestebanparraparra8531 4 ай бұрын
I must say you are one of the greatest coding teachers I have ever seen! Thanks John!
@clarence9527
@clarence9527 Жыл бұрын
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.
@GuilhermePalazzoRodrigues
@GuilhermePalazzoRodrigues 2 жыл бұрын
This course is a gem, concise, clear and thorough, thank you!
@afrasm2478
@afrasm2478 2 жыл бұрын
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
@jilliansechrest5906
@jilliansechrest5906 2 жыл бұрын
You are a phenomenal instructor - you saved my behind in data structures and algorithms and this was a great refresher on lambdas.
@alexj1580
@alexj1580 2 жыл бұрын
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.
@phonesj3422
@phonesj3422 2 жыл бұрын
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!!!
@janmour8089
@janmour8089 2 ай бұрын
Finally a human explanation ! Thank you so much !
@simongraham2516
@simongraham2516 2 жыл бұрын
Never came across a more clearer explanation!
@backtashmohammadi2231
@backtashmohammadi2231 3 ай бұрын
I am really impressed by how good you explain each method. THANK YOU
@dreamtreater
@dreamtreater 11 ай бұрын
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.
@suwatchainanchai6637
@suwatchainanchai6637 Жыл бұрын
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
@oleksandr3275
@oleksandr3275 2 жыл бұрын
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 !
@lemonghost5591
@lemonghost5591 2 жыл бұрын
Absoultly clear and concise! Thanks alot!
@1234567mrbob
@1234567mrbob 2 жыл бұрын
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.
@KMJMusic
@KMJMusic 2 жыл бұрын
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
@ziqimage
@ziqimage 2 жыл бұрын
The quality of this channel, no word.
@KRaJWanders
@KRaJWanders 5 ай бұрын
one of the best videos on Lamda Short and to the point Thanks @CodingWithJohn
@danteUp
@danteUp 7 ай бұрын
Amazing video. Clear and precise. Thanks for that
@nikosaspridis8091
@nikosaspridis8091 10 ай бұрын
I am studying cs in university and we had an oop course in java this semester... Thank you very much ! :)
@houdaejbkl5126
@houdaejbkl5126 Жыл бұрын
John ! I want you to know that you're the coolest Java teacher. I injoyed your courses a lot , so THANK YOU !!
@kiraalberiti7609
@kiraalberiti7609 Жыл бұрын
The best explanation i heard until now
@arpanchakraborty9874
@arpanchakraborty9874 6 ай бұрын
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
@technics6215
@technics6215 2 жыл бұрын
The best lambda explanation ever. Thank you!
@omkardeshpande9640
@omkardeshpande9640 2 жыл бұрын
John hats off to your simplicity explanation. You have excellent command in your communication. 👏
@lovsol0
@lovsol0 6 ай бұрын
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
@JohnDoe-ux7hl
@JohnDoe-ux7hl Жыл бұрын
Oh thanks, i'm starting with lambda and this video was perfect. You are amazing.
@ShinMugenNoKabe
@ShinMugenNoKabe 2 жыл бұрын
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
@ivan-Croatian
@ivan-Croatian Жыл бұрын
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!
@ЕкатеринаСекретарева-м9м
@ЕкатеринаСекретарева-м9м Жыл бұрын
The best explanation of lambdas! Thank you so much🙏
@andrezanlorensi
@andrezanlorensi Жыл бұрын
Thank you now i finally understood how lambda works.
@pedroalbertogomes3809
@pedroalbertogomes3809 2 жыл бұрын
I discovered this channel today and already watched about 7 videos. Amazing! Thanks
@AnyNameChannel123
@AnyNameChannel123 2 жыл бұрын
Спасибо большое из Беларуси! (Thanks a lot from Belarus)
@ivankobyuk8385
@ivankobyuk8385 2 жыл бұрын
Huge THANK YOU from Ukrainian developer! / Велике дякую Вам від українського розробника!
@MGtvMusic
@MGtvMusic 2 жыл бұрын
This channel is a goldmine
@shounaksengupta2154
@shounaksengupta2154 2 жыл бұрын
in awe of the quality.
@tarifhalabi
@tarifhalabi 2 жыл бұрын
Clear, concise and to the point. Nice video John.
@elairyx
@elairyx 2 жыл бұрын
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 :)
@JustinBieberFanSA
@JustinBieberFanSA Жыл бұрын
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.
@HeyThereGuy
@HeyThereGuy 2 жыл бұрын
Listen bro, this is the best explanation of Lambda's I've seen on KZbin. Great job. I just subscribed.
@dannggg
@dannggg 2 жыл бұрын
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
@HassanAlavinezhad-c5v
@HassanAlavinezhad-c5v Жыл бұрын
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.
@christianbarnay2499
@christianbarnay2499 9 ай бұрын
Which can be implemented as a static method. Lambdas are just a way to write unnamed functions and make debugging harder.
@Preelu
@Preelu 8 ай бұрын
Thank you for this tutorial! Now, I understand lambda in Java.
@misaelpereira9679
@misaelpereira9679 2 жыл бұрын
Never have seen a so clearly explanation about java lambdas. You rock!
@moyolinux
@moyolinux Жыл бұрын
not bad quick and insightful, defiantly helps with the lambdas section on headfirst java
@ashuiet
@ashuiet 2 жыл бұрын
Very clean explanation !! Thanks @Coding With John.
@slhx8956
@slhx8956 2 жыл бұрын
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!
@curtisdevine2953
@curtisdevine2953 Жыл бұрын
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!
@rlasc84
@rlasc84 2 жыл бұрын
Hi John. Your videos are making me consider use java again in my projects
@actualprogramming
@actualprogramming 2 жыл бұрын
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.
@dumpsockpuppet5619
@dumpsockpuppet5619 2 жыл бұрын
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
@TechSY730
@TechSY730 2 жыл бұрын
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)
@LaraRoss-f7c
@LaraRoss-f7c 24 күн бұрын
Finally I understood this lambda expression thing. I came form JavaScript and Java's Lamda Expression is so confusing.
@Jaksteroide
@Jaksteroide 7 ай бұрын
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!
@jalilhasanli5577
@jalilhasanli5577 2 жыл бұрын
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.
@fernandobondar7105
@fernandobondar7105 7 ай бұрын
Just blow my mind. Finally can understand the sintax behind the lambda
@shubhtyagi1
@shubhtyagi1 2 жыл бұрын
After watching so many videos, its first time I'm feeling that it's the best explanation 👍
@joswinprince9474
@joswinprince9474 2 жыл бұрын
Good man....explained with confidence and clear
@cr8444
@cr8444 2 жыл бұрын
Again! my subscription to your channel is never a waste. God you are such a good teacher!! Thank you again for this 💃💃💃
@beth8able
@beth8able 9 ай бұрын
This tutorial was concise and precise, thank you for such a clear explanation!!!
@khiemdo5527
@khiemdo5527 2 жыл бұрын
Waiting for this topic for a long time, and it has been delivered more than enough. Thanks John so much
@ilunghi
@ilunghi 2 жыл бұрын
+1, he's totally nailed it once again
@chinmayrath8494
@chinmayrath8494 2 жыл бұрын
Clear, concise, to the point, thanks a lot !! Helped a lot
@mythilikalidasan
@mythilikalidasan 2 жыл бұрын
Most wanted tutorial from you!!! Thanks :)
@Rasmusorum
@Rasmusorum 2 жыл бұрын
best programming teacher
@ferroalloys594
@ferroalloys594 Ай бұрын
The syntactic and semantic beauty of functions always and only ABSTRACTING OVER EXPRESSIONS! Wicked... (:-)
@JapaneseRedhead
@JapaneseRedhead Жыл бұрын
Lambdas allow you "to effectively treat code as a parameter". Thank you!
@gonsalomon
@gonsalomon 2 жыл бұрын
Awesome. Now not only JavaScript has arrow functions, but also Java. It's lovely for someone working on web development as well.
@shankar7435
@shankar7435 2 жыл бұрын
Excellent explanation on Lamdas.
@ilyaJUNiOR
@ilyaJUNiOR Жыл бұрын
My English level a2-b1 but l enjoy watching your videos 😊 Thank you for your hard work.
@AlexRubyTV
@AlexRubyTV 2 жыл бұрын
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.
@cfpls
@cfpls 2 жыл бұрын
I love how you explain concepts
@rohitkharche7562
@rohitkharche7562 2 жыл бұрын
Now this makes perfect background for "Streams", please make a video on that also. 🙂
@aidoka2000
@aidoka2000 2 жыл бұрын
excellent explanation of Java. Thanks John for the amazing tutorials.
@gtiradob
@gtiradob 4 ай бұрын
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.
@yuriytheone
@yuriytheone Жыл бұрын
Thanks! Best exlanation of lambda funvtions.
@pattyboi55
@pattyboi55 2 жыл бұрын
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!
@patrickfrankdjengoue8734
@patrickfrankdjengoue8734 2 жыл бұрын
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. 😃😃
@matimozg
@matimozg Жыл бұрын
Thanks, man it's very helpful explanation of this topic. I needed help with return type lambda implementation.
@susanthapathirana9195
@susanthapathirana9195 Жыл бұрын
This simple and best video to understand lambda. Good one John.
Optionals In Java - Simple Tutorial
15:53
Coding with John
Рет қаралды 220 М.
Generics In Java - Full Simple Tutorial
17:34
Coding with John
Рет қаралды 1,1 МЛН
This Game Is Wild...
00:19
MrBeast
Рет қаралды 160 МЛН
FOREVER BUNNY
00:14
Natan por Aí
Рет қаралды 27 МЛН
How Many Balloons To Make A Store Fly?
00:22
MrBeast
Рет қаралды 108 МЛН
Real Man relocate to Remote Controlled Car 👨🏻➡️🚙🕹️ #builderc
00:24
Functional Interface | Lambda Expression in Java
13:56
Telusko
Рет қаралды 159 М.
5 Signs of an Inexperienced Self-Taught Developer (and how to fix)
8:40
Java Strings are Immutable - Here's What That Actually Means
7:06
Coding with John
Рет қаралды 622 М.
Static vs Non-Static Variables and Methods In Java - Full Simple Tutorial
11:29
Java 8 STREAMS Tutorial
18:10
Oggi AI - Artificial Intelligence Today
Рет қаралды 745 М.
.equals() vs. == in Java - The Real Difference
8:48
Coding with John
Рет қаралды 195 М.
Set and HashSet in Java - Full Tutorial
20:43
Coding with John
Рет қаралды 232 М.
This Game Is Wild...
00:19
MrBeast
Рет қаралды 160 МЛН