#42 This keyword in Java

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 will see:
- Instance variable and Local variable
- Can we declare two or more variables with the same name?
- This keyword and its uses in Java

#1
Instance variable:- These variables are declared within a class but outside a method.
- These variables are created when we create an object and are destroyed when the object is destroyed.

Local variable:- These variables are declared within a method but do not get any default value.
- They are created when we enter a method or constructor and get destroyed when the call returns from the method.

#2
In Java, it is not allowed to declare two or more variables having the same name inside a scope either in class scope or method scope.
- The preference is always given to the local variable.
- Creating an object is not a good idea to solve the issue of conflicting names of instance and local variables.
- We can differentiate between local and instance variables by passing an object itself.
- Instead of writing and passing an object, we can simply use this keyword.

#3
This keyword:-
This keyword represents the current object.
- Current object is an object which is calling the method.
- This keyword is used to invoke the current class constructor.
- Using the 'this' keyword, we can return the current class instance.
- This keyword can be used as an argument in the constructor call.

More Learning :

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

bro used entire 9 minutes just to define a single keyword, this shows he wants us to learn deeply 🙇🔥

karthi
Автор

I was learning java for project requirement and this video saved my life to understand this in java it is weird but understood :) No one can escape this three languages in their life java, python and js

Viralvlogvideos
Автор

Iam here from JS and i know the function of this keyword but when i was a beginner it was a huge headache for me. But after this video I can clearly state that Navin reddy sir aka telusko is one of the best teacher ever. Genius, the way he explained about this keyword..

sandybeast_sb
Автор

Like me a person love details and how things works. I watched alot of tutorials about java and difficult topics like consturtor and this keyword, implicitly I understand it but I can't move without understanding initial way for things work. Your explaining with more fantastic details and different way, you are amazing . Thank you alot my teacher

HishamMohammed-gheh
Автор

Amazing Explanation sir. Trying out different possibilities and explaining really nice

immadisettivarun
Автор

Your way of explaining things is fantastic. Thank you.

Headcator
Автор

Best explanation ever!
I can't thank you enough for these amazing tutorials sir.

Yashila_Jonnada
Автор

The best Java teacher I have ever seen. Explanations, Examples are perfect

sahinsevinc
Автор

Thankyou sir ❤ keep teaching us like this. More respect to you sir.

heytanibhi
Автор

I watched many videos to understand how this keyword works, but none of them helped me. This video cleared all my doubts and questions. Thank you, sir, for this lecture!

vishalrohera
Автор

Grateful for this Playlist ...thank you!

TreatsNTravelsByJaaiPawar
Автор

Thanks a ton sir, now the confusion got cleared for me for THIS keyword…. Your explanation is irreplaceable…🥰🥰🥰🥰🥰

sathya
Автор

best explanation
quality content fr🙂

Luffy_
Автор

THIS is the only time I have ever understood the THIS keyword. Thank you so much!! So does that mean that the This keyword is only used in NON-STATIC methods?

darswayeeyou
Автор

bro why do you look so humble ❤️ thanks for the videos anna..!!

CHALLENGESTORY
Автор

Hey Navin sir! Your fan from Nepal! <3

abhiiiydv
Автор

This video shows your passion towards teaching, great work sir, I'm impressed 👏🏼

VarunGowda-horm
Автор

00:02 Understanding the 'this' keyword in Java
01:14 In Java, the stack memory and heap memory are used for different purposes.
02:27 Local and instance variables with the same name in Java
03:43 Assigning a variable to itself in Java can lead to unexpected behavior.
04:55 In Java, 'this' refers to the current object instance.
06:04 Creating a new object may cause issues with assigning values.
07:19 Passing object references and differentiating between instance and local variables in Java
08:36 The 'this' keyword represents the current object in Java

karthikplays
Автор

hi Navin, pls make a video on passing this keyword into methd arguements and passing this keyword as arguments in parameterised constructors

raghukumar
Автор

I really helped me in understanding this, thanks ❤

Kaviarasu_NS