#42 This keyword in Java

Sdílet
Vložit
  • čas přidán 29. 08. 2024
  • Check out our courses:
    Enterprise Java Spring Microservices: go.telusko.com...
    Coupon: TELUSKO10 (10% Discount)
    Master Java Spring Development : bit.ly/java-sp...
    Coupon: TELUSKO20 (20% Discount)
    Udemy Courses:
    Java:- bit.ly/JavaUde...
    Spring:- bit.ly/SpringU...
    Java For Programmers:- bit.ly/javaPro...
    For More Queries WhatsApp or Call on : +919008963671
    website : courses.telusk...
    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

Komentáře • 54

  • @karthi7490
    @karthi7490 Před 3 měsíci +31

    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 Před 9 dny

      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.

  • @Viralvlogvideos
    @Viralvlogvideos Před rokem +10

    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

  • @karthikplays69
    @karthikplays69 Před 5 měsíci +2

    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

  • @danl8994
    @danl8994 Před 17 dny +1

    Excellent way of teaching.
    Pushes us to wrong path only to make us understand the right path. Thank you.

  • @sandybeast07_sb
    @sandybeast07_sb Před měsícem +1

    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..

  • @immadisettivarun
    @immadisettivarun Před rokem +7

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

  • @HishamMohammed-gh7eh
    @HishamMohammed-gh7eh Před rokem +3

    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

  • @Yashila_Jonnada
    @Yashila_Jonnada Před rokem +4

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

  • @sahinsevinc41
    @sahinsevinc41 Před 8 měsíci +1

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

  • @vishalrohera4328
    @vishalrohera4328 Před 3 měsíci

    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!

  • @darswayeeyou
    @darswayeeyou Před rokem +2

    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?

  • @Headcator
    @Headcator Před rokem +1

    Your way of explaining things is fantastic. Thank you.

  • @ManishTamrakar-w7j
    @ManishTamrakar-w7j Před 25 dny +1

    I literally clapped when this was used at last

  • @heytanibhi
    @heytanibhi Před 11 měsíci +1

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

  • @MaxChan-zw8cx
    @MaxChan-zw8cx Před 20 dny

    you are excellent at java concepts

  • @VarunGowda-ho2rm
    @VarunGowda-ho2rm Před 3 měsíci

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

  • @sadhanarealty
    @sadhanarealty Před 6 měsíci +5

    Take simple example

  • @CHALLENGESTORY
    @CHALLENGESTORY Před 9 měsíci +1

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

  • @faheelansari7353
    @faheelansari7353 Před měsícem

    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

  • @smrpkrl
    @smrpkrl Před rokem +2

    Hey Navin sir! Your fan from Nepal!

  • @Luffy_2804
    @Luffy_2804 Před rokem +1

    best explanation
    quality content fr🙂

  • @sathya8242
    @sathya8242 Před rokem

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

  • @vihangjoshi7525
    @vihangjoshi7525 Před rokem +1

    Great way of explanation

  • @vicks3258
    @vicks3258 Před 2 měsíci

    Wow great concept Thanks you so much❤

  • @raghukumar8184
    @raghukumar8184 Před rokem

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

  • @souvikkundu
    @souvikkundu Před 9 měsíci

    Perfectly explained. Thank you.

  • @technocratsworld214
    @technocratsworld214 Před 4 měsíci

    brilliant explanation

  • @TreatsNTravelsByJaaiPawar

    Grateful for this Playlist ...thank you!

  • @SumanMondal-gv8bi
    @SumanMondal-gv8bi Před 4 měsíci

    Thanks for the explaination Sir.

  • @sivadon4065
    @sivadon4065 Před 11 měsíci

    Happy teacher's day sir🎉🎉🎉

  • @Kaviarasu_NS
    @Kaviarasu_NS Před 6 měsíci

    I really helped me in understanding this, thanks ❤

  • @atulsolanki2519
    @atulsolanki2519 Před rokem

    Excellent explanation ,thanks😊

  • @TECHWITHKAMALRAJ
    @TECHWITHKAMALRAJ Před měsícem

    Java means Telusko ❤

  • @3lpme
    @3lpme Před měsícem

    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 ?

  • @sankarsubramanian6312

    Thanks Naveen 🔥 Big fan 💥

  • @Vinaygoud1264
    @Vinaygoud1264 Před 9 měsíci

    Super sir

  • @nithintjoy6742
    @nithintjoy6742 Před 10 měsíci

    one doubt, if we are not using this key word and just using two different variable names..will it work?

    • @karots77
      @karots77 Před 7 měsíci

      yeah it will work

  • @jatinsharma3792
    @jatinsharma3792 Před 7 měsíci

    What do you mean by the current object !?

    • @karots77
      @karots77 Před 7 měsíci +1

      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 Před 7 měsíci

      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

  • @ShubhamVerma-nu3ze
    @ShubhamVerma-nu3ze Před 10 měsíci

    great teacher love you

  • @syedadil7256
    @syedadil7256 Před rokem +1

    Lil bit confusion sir.

  • @MahidharYouTube
    @MahidharYouTube Před měsícem

    varayyo vammo...entha baga cheppav babai.

  • @CHALLENGESTORY
    @CHALLENGESTORY Před 9 měsíci

    line 30
    obj.setAge(age: 30); // how did he type this inside the bracket--> age:

    • @Telusko
      @Telusko  Před 9 měsíci

      Inlay hints added by vs code (not a part of the code)
      Not written by me.

    • @CHALLENGESTORY
      @CHALLENGESTORY Před 9 měsíci

      @@Telusko oh, I'm learning java using Eclipse which is why I was unaware..thanks bro..

  • @0shaad
    @0shaad Před rokem

    we cant call local variable outside of its local context

  • @someshwarreddy8463
    @someshwarreddy8463 Před měsícem

  • @pradeepdeeps2832
    @pradeepdeeps2832 Před 8 měsíci

    That's a lot of THIS😂

  • @sarthak-salunke
    @sarthak-salunke Před 8 měsíci

    🙏❣

  • @rounaksingh3255
    @rounaksingh3255 Před rokem

    sir khud he kyu padh rahe ho