#42 This keyword in Java

  Рет қаралды 182,575

Telusko

Telusko

Күн бұрын

Check out our courses:
Java Full Stack and Spring AI - go.telusko.com...
Coupon: TELUSKO10 (10% Discount)
DevOps with AWS: From Basics to Mastery : go.telusko.com...
Coupon: TELUSKO10 (10% Discount)
Master Java Spring Development : go.telusko.com...
Coupon: TELUSKO20 (20% Discount)
For More Queries about Course, WhatsApp or Call: +919008963671
website : www.telusko.com/
Instagram : / navinreddyofficial
Linkedin : / navinreddy20
TELUSKO Android App : bit.ly/TeluskoApp
TELUSKO IOS App : apple.co/3SsgmU2
Discord : / discord
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.
Github repo : github.com/nav...
Java:- bit.ly/JavaUde...
Spring:- bit.ly/SpringU...
More Learning :
Java :- bit.ly/3x6rr0N
Python :- bit.ly/3GRc7JX
Django :- bit.ly/3MmoJK6
JavaScript :- bit.ly/3tiAlHo
Node JS :- bit.ly/3GT4liq
Rest Api :-bit.ly/3MjhZwt
Servlet :- bit.ly/3Q7eA7k
Spring Framework :- bit.ly/3xi7buh
Design Patterns in Java :- bit.ly/3MocXiq
Docker :- bit.ly/3xjWzLA
Blockchain Tutorial :- bit.ly/3NSbOkc
Corda Tutorial:- bit.ly/3thbUKa
Hyperledger Fabric :- bit.ly/38RZCRB
NoSQL Tutorial :- bit.ly/3aJpRuc
Mysql Tutorial :- bit.ly/3thpr4L
Data Structures using Java :- bit.ly/3MuJa7S
Git Tutorial :- bit.ly/3NXyCPu
Donation:
PayPal Id : navinreddy20
www.telusko.com

Пікірлер: 70
@karthikplays69
@karthikplays69 11 ай бұрын
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
@abhirathour6682
@abhirathour6682 4 ай бұрын
thanks brother ...
@karthi7490
@karthi7490 9 ай бұрын
bro used entire 9 minutes just to define a single keyword , this shows he wants us to learn deeply 🙇🔥
@sai_teja_ig
@sai_teja_ig 5 ай бұрын
while learning java i had realised that java is easier than java script bcoz in java script to explain the this keyword it will take easily an hour.
@adyan4010
@adyan4010 2 ай бұрын
@@sai_teja_ig java and javascript are completely different so why compare?
@Viralvlogvideos
@Viralvlogvideos Жыл бұрын
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
@danl8994
@danl8994 6 ай бұрын
Excellent way of teaching. Pushes us to wrong path only to make us understand the right path. Thank you.
@sandybeast07_sb
@sandybeast07_sb 7 ай бұрын
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..
@vishalrohera4328
@vishalrohera4328 8 ай бұрын
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!
@sahinsevinc41
@sahinsevinc41 Жыл бұрын
The best Java teacher I have ever seen. Explanations, Examples are perfect
@immadisettivarun
@immadisettivarun Жыл бұрын
Amazing Explanation sir. Trying out different possibilities and explaining really nice
@Yashila_Jonnada
@Yashila_Jonnada Жыл бұрын
Best explanation ever! I can't thank you enough for these amazing tutorials sir.
@VarunGowda-ho2rm
@VarunGowda-ho2rm 9 ай бұрын
This video shows your passion towards teaching, great work sir, I'm impressed 👏🏼
@HishamMohammed-gh7eh
@HishamMohammed-gh7eh Жыл бұрын
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
@darswayeeyou
@darswayeeyou Жыл бұрын
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?
@1stGames
@1stGames 5 ай бұрын
superb, i will never ever forget this keyword again, Thank you
@Headcator
@Headcator Жыл бұрын
Your way of explaining things is fantastic. Thank you.
@sathya8242
@sathya8242 Жыл бұрын
Thanks a ton sir, now the confusion got cleared for me for THIS keyword…. Your explanation is irreplaceable…🥰🥰🥰🥰🥰
@CHALLENGESTORY
@CHALLENGESTORY Жыл бұрын
bro why do you look so humble ❤️ thanks for the videos anna..!!
@technocratsworld214
@technocratsworld214 10 ай бұрын
brilliant explanation
@neboeleyazer4186
@neboeleyazer4186 5 ай бұрын
public void setAge(int age, Human obj) { obj.age = age; } also works instead of creation a new object
@NileshNath-vb4fp
@NileshNath-vb4fp 3 ай бұрын
He said that too, you missed it ig
@vicks3258
@vicks3258 8 ай бұрын
Wow great concept Thanks you so much❤
@faheelansari7353
@faheelansari7353 6 ай бұрын
Can we say that constructor return this that is why we can use to access instance variable Like Human obj = new Human(); //Human(); It is constructor call
@ajayghode3602
@ajayghode3602 Ай бұрын
Thank You. Nice explanation diagrammatically.
@heytanibhi
@heytanibhi Жыл бұрын
Thankyou sir ❤ keep teaching us like this. More respect to you sir.
@Luffy_2804
@Luffy_2804 Жыл бұрын
best explanation quality content fr🙂
@gedecandra7722
@gedecandra7722 2 ай бұрын
This is very good explanation 👍
@raghukumar8184
@raghukumar8184 Жыл бұрын
hi Navin , pls make a video on passing this keyword into methd arguements and passing this keyword as arguments in parameterised constructors
@smrpkrl
@smrpkrl 2 жыл бұрын
Hey Navin sir! Your fan from Nepal!
@Kaviarasu_S
@Kaviarasu_S 11 ай бұрын
I really helped me in understanding this, thanks ❤
@souvikkundu
@souvikkundu Жыл бұрын
Perfectly explained. Thank you.
@TreatsNTravelsByJaaiPawar
@TreatsNTravelsByJaaiPawar Жыл бұрын
Grateful for this Playlist ...thank you!
@atulsolanki2519
@atulsolanki2519 Жыл бұрын
Excellent explanation ,thanks😊
@SumanMondal-gv8bi
@SumanMondal-gv8bi 10 ай бұрын
Thanks for the explaination Sir.
@vihangjoshi7525
@vihangjoshi7525 2 жыл бұрын
Great way of explanation
@MaxChan-zw8cx
@MaxChan-zw8cx 6 ай бұрын
you are excellent at java concepts
@sivadon4065
@sivadon4065 Жыл бұрын
Happy teacher's day sir🎉🎉🎉
@Le.Vi.No7
@Le.Vi.No7 3 ай бұрын
finally understood the true meaning of "this"
@techcuriouscoder
@techcuriouscoder 9 күн бұрын
Salute you sir 🔥💯
@ManishTamrakar-w7j
@ManishTamrakar-w7j 6 ай бұрын
I literally clapped when this was used at last
@Vardanaggarwal
@Vardanaggarwal 3 ай бұрын
Amazing.
@sankarsubramanian6312
@sankarsubramanian6312 2 жыл бұрын
Thanks Naveen 🔥 Big fan 💥
@contactnehajain
@contactnehajain 3 ай бұрын
beautifully explained by going wrong ways.. no one can ever forget this
@Telusko
@Telusko 3 ай бұрын
Learning by mistakes is the best way 😉
@atharvat223
@atharvat223 Ай бұрын
Instead of setage or setname why can't we set it with a constructor and then use a method to return the value ?
@KARLAPATIARJUN
@KARLAPATIARJUN 18 күн бұрын
Why should we use this keyword in first statement of the method always? what happens if we not?
@TECHWITHKAMALRAJ
@TECHWITHKAMALRAJ 6 ай бұрын
Java means Telusko ❤
@nithintjoy6742
@nithintjoy6742 Жыл бұрын
one doubt, if we are not using this key word and just using two different variable names..will it work?
@karots77
@karots77 Жыл бұрын
yeah it will work
@jatinsharma3792
@jatinsharma3792 Жыл бұрын
What do you mean by the current object !?
@karots77
@karots77 Жыл бұрын
I think you are asking it for this keyword am I correct? if that is your question, Then whenever you create an object it cannot use the variable directly so we need to use methods to access it, when you create an object to modify those values using methods those object are the current object for the "this" keyword (this is not a correct answer this is what i understand so far)
@jatinsharma3792
@jatinsharma3792 Жыл бұрын
No, I sometimes didn't get what he meant, :D I understood about this keyword, I know It refer to the current class object, we use in many ways, for builder pattern and for constructor to set the values so we define it and distigawise between local and global var, I don't care much much he don't explain the internal thing, so for refresh it is fine but not for the real knowledge. @@karots77
@DCtough
@DCtough 6 ай бұрын
Can anyone one help me to understand ? I didn't understand at this "when we call age function we are passing the value ?👀 But why the heck we did we get zero, what's happening if we mention local and instance variable as same name ?
@syedadil7256
@syedadil7256 Жыл бұрын
Lil bit confusion sir.
@Vinaygoud1264
@Vinaygoud1264 Жыл бұрын
Super sir
@sadhanarealty
@sadhanarealty Жыл бұрын
Take simple example
@MahidharYouTube
@MahidharYouTube 7 ай бұрын
varayyo vammo...entha baga cheppav babai.
@ShubhamVerma-nu3ze
@ShubhamVerma-nu3ze Жыл бұрын
great teacher love you
@CHALLENGESTORY
@CHALLENGESTORY Жыл бұрын
line 30 obj.setAge(age: 30); // how did he type this inside the bracket--> age:
@Telusko
@Telusko Жыл бұрын
Inlay hints added by vs code (not a part of the code) Not written by me.
@CHALLENGESTORY
@CHALLENGESTORY Жыл бұрын
@@Telusko oh, I'm learning java using Eclipse which is why I was unaware..thanks bro..
@0shaad
@0shaad Жыл бұрын
we cant call local variable outside of its local context
@mr.explorer9502
@mr.explorer9502 5 ай бұрын
why to use same name for variables use different and all problems solved
@ragul5679
@ragul5679 4 ай бұрын
thank god kadavul one ha padachan da 4 lakhs wasted on college
@pradeepdeeps2832
@pradeepdeeps2832 Жыл бұрын
That's a lot of THIS😂
@someshwarreddy8463
@someshwarreddy8463 7 ай бұрын
@sarthak-salunke
@sarthak-salunke Жыл бұрын
🙏❣
@rounaksingh3255
@rounaksingh3255 Жыл бұрын
sir khud he kyu padh rahe ho
#43 Constructor in Java
7:05
Telusko
Рет қаралды 212 М.
SHE CAME BACK LIKE NOTHING HAPPENED! 🤣 #shorts
00:21
Joe Albanese
Рет қаралды 19 МЛН
Banana vs Sword on a Conveyor Belt
01:00
Mini Katana
Рет қаралды 77 МЛН
#51 This and Super Method in Java
12:11
Telusko
Рет қаралды 148 М.
#61 Abstract Keyword in Java
12:09
Telusko
Рет қаралды 200 М.
#26 Stack And Heap in Java
12:37
Telusko
Рет қаралды 322 М.
I made Tetris in C, this is what I learned
15:15
Austin Larsen
Рет қаралды 31 М.
10 Important Python Concepts In 20 Minutes
18:49
Indently
Рет қаралды 507 М.
USAGE OF THIS KEYWORD - JAVA PROGRAMMING
11:12
Sundeep Saradhi Kanthety
Рет қаралды 105 М.
#40 Encapsulation in Java
11:42
Telusko
Рет қаралды 233 М.
This Keyword in Java Full Tutorial - How to Use "this"
7:39
Coding with John
Рет қаралды 165 М.
#52 Method Overriding in Java
7:57
Telusko
Рет қаралды 185 М.