Java 8 Lambda Basics 20 - The this reference in lambdas

  Рет қаралды 128,788

Java Brains

Java Brains

Күн бұрын

Пікірлер: 35
@dennyjames6120
@dennyjames6120 5 жыл бұрын
Really awesome Tutorials on Lambda! Thanks Koushik! Just to add a small point on the subject, if we take a look at the compiled .class files, we could see that Lambdas as never converted to .class files. At the same time we can see Anonymous inner class getting converted to individual .class files. This behavior can be correlated to the fact that Lambdas are not syntactical sugar over anonymous inner class, but a different thing on its own.
@botrate412
@botrate412 3 жыл бұрын
Wow after spending 1.5 yrs in java today I got to learn something new about lambda
@83kumarvishal
@83kumarvishal 7 жыл бұрын
actually when you see the .class files, we wont see any inner class starting with $.. that explains lambda are not converted as anaynomus inner class
@readerwriter-gf5iy
@readerwriter-gf5iy 6 жыл бұрын
Sir ji awesome! I came to this clip from your fist clip from this tutorial series.
@OvidiuCONEAC
@OvidiuCONEAC 7 жыл бұрын
Excellent explanation! Thank you!
@elmehdisaniss2731
@elmehdisaniss2731 4 жыл бұрын
You are very awesome ! I'm learning so much from you ! Thank you so much.
@adelsalaheldeen
@adelsalaheldeen 5 жыл бұрын
These videos are awesome really. I just have one small question in this video and hope someone sees my comment. In demonstrating the anonymous inner class with "this" reference ( before adding the toString method override), why it prints an instance of ThisReferenceExample class, not the inner class (on 3:49)?
@4jilson
@4jilson 5 жыл бұрын
Actually, it prints the instance of the inner class, the name of the inner class is displayed after the $ sign, As the inner class is an anonymous class hence its name is like some code value. You can check this code github.com/jilsonjoseph/Java/blob/master/Inner%20Class/Main.java it displays the name of Inner class as I have used a name for my inner class (because here my class is not an anonymous class).
@haolinzhang53
@haolinzhang53 2 жыл бұрын
Same question.
@rookiecookie47
@rookiecookie47 8 жыл бұрын
that's why anonymous classes and lambdas are different things
@MrAbbydarappa
@MrAbbydarappa 6 жыл бұрын
Add to it the fact you cannot have more than 1 method?
@yashkumarm743
@yashkumarm743 4 жыл бұрын
one Question even when you print this object in the Anynomus Inner class it prints ThisReferenceExample only not the Process Object could you please check that
@thenullpointer6386
@thenullpointer6386 3 жыл бұрын
in the Anynomus Inner class it prints ThisReferenceExample -> it prints the inner class reference only, there is a $ symbol in the output. which shows inner class object
@amitmahto68
@amitmahto68 3 жыл бұрын
public class ThisReferenceExample{ public static void main(String[] args) { Process w=new Process() { @Override public void process(int i) { // TODO Auto-generated method stub System.out.println(this); } }; w.work(0); } } This example is also printing the reference to ThisReferenceExample. Does interfaces when directly implemented as anonymous inner class,also not touch the "this" reference?
@haolinzhang53
@haolinzhang53 2 жыл бұрын
Same question ...
@murthyinutube
@murthyinutube Жыл бұрын
a lambda expression is a concise way to represent an anonymous function, that can be used as an argument for functional interfaces. One key characteristic of lambda expressions is that they capture the values of variables from their enclosing scope. However, when using this within a lambda expression inside a static method, you might encounter an error or unexpected behavior. This is because this refers to the instance of the current class, and in a static context, there is no instance context available. - When a lambda expression is used within an instance method, it can access instance variables and methods using this. - When a lambda expression is used within a static method, it cannot access instance variables and methods using this, as there is no instance context in a static context.
@onlinetvoffical
@onlinetvoffical 6 жыл бұрын
Awesome videos! Please prepare advance lambda
@ramlakhan-fp7ct
@ramlakhan-fp7ct 5 жыл бұрын
Can you please upload a course related to streams, Grouping and ParallelStreams ?
@JustFw6881
@JustFw6881 5 жыл бұрын
Please can anyone explain why it's not a static method anymore? 7:25
@dennyjames6120
@dennyjames6120 5 жыл бұрын
Because he wanted to demonstrate how 'this' behaves in the context of a lambda. He would get a compiler error if he tries to access 'this' on a static method.
@perschistence2651
@perschistence2651 4 жыл бұрын
Uff the javabrains.io link seems to be down.
@aaroldaaroldson708
@aaroldaaroldson708 7 жыл бұрын
So is it the only difference?
@kapilthukral618
@kapilthukral618 Жыл бұрын
this reference behaves in the same way in javascript lambda functions(anonymous functions) as well.
@jaykishankapat41284
@jaykishankapat41284 5 жыл бұрын
excellent
@TheGuroguro12
@TheGuroguro12 8 жыл бұрын
Thank you very much.
@samw4629
@samw4629 8 жыл бұрын
hibernate jdk8
@TheYogi003
@TheYogi003 7 жыл бұрын
8:10 That === though.
@Java.Brains
@Java.Brains 7 жыл бұрын
See kids? This is what happens when you code in both Java and JavaScript!
@kidslearningscience
@kidslearningscience 6 жыл бұрын
Can you please create a video on datadog configuration.
@sonaraw4895
@sonaraw4895 4 жыл бұрын
Excellent course!!!!!!!!!! Request you to add one more playlist on streaming in details would be highly appreciated.
@csamarnathreddy
@csamarnathreddy 8 жыл бұрын
can anyone please suggest a tutorial on Spring Boot
@karuppuswamybe
@karuppuswamybe 8 жыл бұрын
Search for Spring boot by java brains.
@satyas3136
@satyas3136 4 жыл бұрын
Awesome video, but no doubt why java is lagging behind Python, when python is bringing new API wrt AI , ML , DS java is focussing on this nonsense stuff of rewriting same stuff in different way.
@emadrefai9380
@emadrefai9380 4 жыл бұрын
Great work , really useful , I've just one comment or advice , try to make the video shorter by focusing on the important parts , with all my respect
Java 8 Lambda Basics 21 - Method References
10:27
Java Brains
Рет қаралды 175 М.
Lambda Expressions in Java - Full Simple Tutorial
13:05
Coding with John
Рет қаралды 796 М.
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН
Beat Ronaldo, Win $1,000,000
22:45
MrBeast
Рет қаралды 158 МЛН
黑天使被操控了#short #angel #clown
00:40
Super Beauty team
Рет қаралды 61 МЛН
Java 8 Lambda Basics 14 - Lambda Exercise Solution
17:32
Java Brains
Рет қаралды 236 М.
Java Strings are Immutable - Here's What That Actually Means
7:06
Coding with John
Рет қаралды 628 М.
Java 8 Lambda Basics 19 - Closures in Lambda Expressions
8:30
Java Brains
Рет қаралды 148 М.
Method Reference in Java 8
21:06
Telusko
Рет қаралды 190 М.
Java 8 Lambda Basics 23 - Introduction To Streams
11:26
Java Brains
Рет қаралды 181 М.
Functional Interface | Lambda Expression in Java
13:56
Telusko
Рет қаралды 167 М.
Better Java Streams with Gatherers - JEP Cafe #23
1:13:32
Java 8 Lambda Basics 18 - An Exception Handling Approach
9:25
Java Brains
Рет қаралды 148 М.
Java 8 Streams API
15:45
Defog Tech
Рет қаралды 155 М.
Java 8 Lambda Basics 7 - Lambda Expression Examples
9:51
Java Brains
Рет қаралды 418 М.
Каха и дочка
00:28
К-Media
Рет қаралды 3,4 МЛН