This Keyword in Java Tutorial #80

Поделиться
HTML-код
  • Опубликовано: 6 ноя 2024

Комментарии • 190

  • @alexlorenlee
    @alexlorenlee  Год назад +4

    If you’re new to programming but want a career in tech, I HIGHLY RECOMMEND applying to one of Springboard’s online coding bootcamps (use code ALEXLEE for $1,000 off): bit.ly/3HX970h

  • @iwatchedthevideo7115
    @iwatchedthevideo7115 5 лет назад +254

    I just went to bed, after watching the lecture video of my babbling uni professor confusing the hell out of us about the this keyword and blasting through 200 incoherent slides. Then this comes up in my recommended! This is so much clearer and I actually understand it now! Thanks! I think Ill just skip my school lectures now and just watch your videoes. Are you planning on doing anything about polymophism and unit testing?

  • @tbinyt
    @tbinyt Год назад +27

    it's a shame that you no longer make Java videos. You explain well and keep it simple. very helpful

  • @asmaabdullah9068
    @asmaabdullah9068 4 года назад +142

    explained a 1.5-hour lecture in 10.5 minutes. Amazing, thank you so much!

    • @maxassasin911
      @maxassasin911 4 года назад +16

      If your professor needed 90 minutes to improperly explain a basic concept.....I feel your pain.

    • @endone3661
      @endone3661 3 года назад +3

      I hate teachers who explained alot of useless things that took an hour to explain 10 minutes lesson

    • @mikebrown5142
      @mikebrown5142 Год назад

      God is Good!
      Matthew 7:7 :)

  • @lutz
    @lutz 5 лет назад +66

    Dude, I've been trying to get into Java for a long time and made amazing progress with some friend's help but geez, this videos are hella helpful.

  • @luka-j-ovanovic
    @luka-j-ovanovic 4 года назад +121

    For anyone who is coming from a Python background, “this” is the same thing as “self”

  • @hien6451
    @hien6451 3 года назад +2

    for me, a person is not good at English, you speak slowly so I can understand clearly. Thanks so much

  • @dylanchan3772
    @dylanchan3772 4 года назад +8

    Thank you so much Alex!!!! i've been taking a java course at a community college over the summer as a high school student and I've struggled so much with the quick pace and loads of reading. But your videos have saved me!!!! Instead of reading for hours and comprehending 5% of it, I can watch a video like this one and instantly understand it!! This is so much better than the textbook!

  • @jacquelinezapatasaavedra1516
    @jacquelinezapatasaavedra1516 Год назад +1

    Please make more videos ! Come back !! You are amazing !!

  • @academicresourcesaccountfo9176
    @academicresourcesaccountfo9176 3 года назад +5

    Alex, you are a gem for us beginners! You just put this out in such ways that are easy for us to digest! Thank you so much, man! God bless you!

  • @amankaushik5833
    @amankaushik5833 4 года назад +4

    This was the best explanation of the "this" keyword. I can't thank you enough...

  • @עדןמזור
    @עדןמזור 5 лет назад +32

    Great video!
    You always do tutotials for EXACTLY what I need to know xD

  • @simon_gergely
    @simon_gergely Год назад +1

    These videos are so helpful,. Pages of complicated textbook chapters explained in 10 minutes. Thanks for doing them!

  • @sree4528
    @sree4528 4 года назад +1

    I need to say you are explain these things in your pretty easy way which is so helpful.

  • @rayenabadlia5766
    @rayenabadlia5766 5 лет назад +9

    We need a tutorial about " super " key word which is used in inheritance plz 🙏 this was so helpful i clicked the thumbs up button before even watching 😅

  • @miguelluizherrera4529
    @miguelluizherrera4529 3 года назад

    I watched my prof cram the discussion of this, static, and methods, and classes in one single lecture and honestly felt like crying.
    Thank you so much for sharing this!!

  • @sayangku9275
    @sayangku9275 4 года назад +1

    i was crying throughout my first year of college man if i knew this channel back then things would probably be easier for me

  • @abdeselamselami4532
    @abdeselamselami4532 4 года назад

    Thanks a lot Alex, for everyone the short-cut of System.out.println() is type sysout + hit buttons ctrl+space.

  • @nicktendocreep
    @nicktendocreep Год назад +1

    bro thank you so much! your vids are a big help Im so happy I can understand this now

  • @benvoisey3942
    @benvoisey3942 5 лет назад +5

    Oh my god. I’m not gonna get into details but you are literally so much help. I started my GCSEs this year, and you are the reason I took computer science. Thank you so much for the inspiration. Still watching after >1 year. ❤️❤️❤️
    Edit: Oh my god why does RUclips hate me. It unsubscribes me from loads of channels. Just realised it happened to this channel. There’s +1 sub for you

  • @milehighgarage
    @milehighgarage 2 года назад

    Great explainer on why the THIS keyword is used in java

  • @josephnagy2566
    @josephnagy2566 3 года назад

    My guy, your videos are more coherent and comprehensible than my IFT210 prof. Keep up the good work, you are literally saving my grade.

  • @ThatguyWitjokes
    @ThatguyWitjokes 4 года назад

    Very clear explanation. 3 videos later, I've got it. Thanks man

  • @melvingx
    @melvingx 2 месяца назад

    THIS actually makes so much sense lol thanks for simplifying

  • @justkleedesigns
    @justkleedesigns 4 года назад

    Awesome Video, helped a lot. You can also just Type syso and then hit the buttons

  • @kvndotcode
    @kvndotcode 3 года назад

    This really helps me alot more in my ON my online class...thanks for the help man!!

  • @zj10
    @zj10 3 года назад

    Good explanation. I was a bit confused when I first started learning about this, but it much clearer now. Thanks!

  • @jyrikgauldurson8169
    @jyrikgauldurson8169 4 года назад +3

    The 'this' keyword is not there so that you can name local variables the same as class members. It is a reference to the instance of a given constructed object. The naming issue occurs because 'a' and 'b' are shadowed by the parameter names. I suggest that viewers take a deeper look into this for a better fundamental understanding of OOP and the 'this' keyword.

    • @edgarwideman737
      @edgarwideman737 4 года назад +1

      Your correct, but these tutorials are for beginners! Unlike useless college professors, this guy explains java in simple language so you can get started, only then is it possible to go in-depth. Almost 50% of students learn more from youtube when getting started in computer science, then from there $$$ school lessons. That's why I skipped college and University altogether and am now a successful android developer.

    • @tawsifiqbalshurid5773
      @tawsifiqbalshurid5773 2 года назад

      a lot of his videos are like this. They are sort of technically wrong. Which is misguiding people.

  • @jake_3745
    @jake_3745 4 года назад

    Nice almost what I was looking for. The only thing that was missing is the useage of this on constructors not just variables

  • @marclesterdelapena8309
    @marclesterdelapena8309 4 года назад

    You're a legend. Thanks for this.

  • @Larichanns
    @Larichanns 5 лет назад

    Please cover oversize arrays! I love your channel

  • @suryamgupta4467
    @suryamgupta4467 4 года назад

    That was an amazing explanation! Thank you so much

  • @jessicabautista8687
    @jessicabautista8687 3 года назад

    I really need this omg thank you so much

  • @ogmine9913
    @ogmine9913 3 года назад

    tysm 😭😭😭 i was so confused

  • @hamsal_khaldi7851
    @hamsal_khaldi7851 3 года назад

    Thanks, you make the life so much easy, bless you

  • @Matt-nx6uu
    @Matt-nx6uu 3 года назад

    I'm beginner-intermediate, ya know, acing my exams basically. No clue what this is used for yet, so cheers if this helps me figure it out lol

  • @MinhTran-sl7kc
    @MinhTran-sl7kc 3 года назад

    Thank you Alex, you made thing very clear. Liked and Subcribed

  • @YW-zm3ds
    @YW-zm3ds 4 года назад

    so helpful, finally understand this this...

  • @Snipesaintme
    @Snipesaintme 11 месяцев назад

    Thank you so much I really needed that

  • @user-qo3ih7vj4n
    @user-qo3ih7vj4n 3 года назад

    I learn so much from your videos

  • @selvamariairudayam5197
    @selvamariairudayam5197 3 года назад

    Very helpful Alex

  • @youareiamurim
    @youareiamurim 5 лет назад +1

    I love your video alex!! Very helpfull....keep going!!👍😊

  • @mrg3921
    @mrg3921 3 года назад

    Nicely done!

  • @nadi6044
    @nadi6044 4 года назад

    Thank you Alex. you are the best 👌👌👌

  • @dname1802
    @dname1802 2 месяца назад

    Thank you so much, you're the best!!!

  • @a99g
    @a99g 6 месяцев назад +1

    What text editor is this?

  • @SnS-SpartaN
    @SnS-SpartaN Год назад +1

    *_I read 'this keyboard'_*

  • @counterpointerz-rocketleag2038
    @counterpointerz-rocketleag2038 3 года назад +1

    Or just ( String _food , char _size) {
    }

  • @ahmadmousa6895
    @ahmadmousa6895 3 года назад

    i would recommend this video for my teacher

  • @Khyrid
    @Khyrid 3 года назад

    I'm learning java at warp speed because of you.

  • @MrLithuanian91
    @MrLithuanian91 4 года назад

    Thanks from Lithuania :)

  • @AkashdeepSingh-qq5fw
    @AkashdeepSingh-qq5fw 3 года назад

    6:00 or maybe simply name the parameters same as the attributes like a and b. But an underscore a_ b_.

  • @joycelillian1815
    @joycelillian1815 4 года назад +1

    I can't help not looking at you when I'm listening to you

  • @tahabekmez5072
    @tahabekmez5072 4 года назад

    I'm a guy but 0:17 the look and tone blew me away!

  • @notyournormaldev1419
    @notyournormaldev1419 3 года назад +1

    Hey !! Alex loved your video .. but can you tell me the name of the song in the background @Alex Lee

  • @adityakadam830
    @adityakadam830 3 года назад +1

    Dude you vids are amazing
    but in this particular video u shudnt have used the class name "Thisisfun"
    Love from India❤️

  • @ibrahimylmaz8378
    @ibrahimylmaz8378 2 года назад

    thank you man

  • @mouminali1380
    @mouminali1380 5 лет назад +1

    Haha where was this when I was studying for a test I had today.
    Btw any plans on doing videos about data structures?

  • @liyasamuel4133
    @liyasamuel4133 4 года назад

    i swear i would not pass my uni course if it wasn't for you alexxx leeeee

  • @chiedozieonyearugbulem9363
    @chiedozieonyearugbulem9363 Год назад

    Instead of saying it could be "confusing", it's better to tell the viewers about scope of variables since that's the reason the variables "a" and "b" weren't changing

  • @46Bax
    @46Bax 3 года назад

    so the one without the this keywoard, will always refer to the variable given through the method ?

  • @sitinorfarhana5510
    @sitinorfarhana5510 3 года назад

    My lecturer just gave me the code and I need to copy paste it into java and see it for myself what it had done TT and tomorrow i have TESTTTTTTT 😭

  • @londiniburro1931
    @londiniburro1931 4 года назад

    thank you dude

  • @aymenzidane7130
    @aymenzidane7130 4 года назад

    great explanation, ta very much. can you tell me about a video to understand new keyword perfectly Sir!!?

  • @scottw7895
    @scottw7895 5 лет назад

    What are the benefits and downsides to this method vs using static variables? You wouldn't have to pass static variables, which is considered best practice?

  • @jatindhiman2261
    @jatindhiman2261 3 года назад

    thank you so much sir

  • @curseditx
    @curseditx 4 года назад

    Plz make a vid on creating our own packages and multiple class....
    And can we do this package program on My phone

  • @michaelcoleman3407
    @michaelcoleman3407 2 года назад

    So basically the “this” keyword doesn’t refer to the values in the parameter?

  • @justinsanesc.9085
    @justinsanesc.9085 2 года назад

    Thank you for this video :)

  • @nhapmonlaptrinh9268
    @nhapmonlaptrinh9268 4 года назад

    very useful video, but how about the " this("string", num), how to use it and why we use it?

    • @ariton2990
      @ariton2990 4 года назад

      The example you provided is call of a constructor for this object. Its useful when you do Constructor Chaining.
      www.geeksforgeeks.org/constructor-chaining-java-examples/

  • @gericofrancisco2013
    @gericofrancisco2013 5 лет назад +4

    So you just use the "this" keyword whenever you are using a globally declared variable or to lessen the use of objects inside your methods.
    Thanks for another good upload brother!
    Keep it up!

  • @only_fair23
    @only_fair23 2 года назад

    Can someone explain why the static won't work with this? Or in what situations static doesn't work? I understand where to use it but don't know why it doesn't work in more situations.

  • @nawfalnjm5699
    @nawfalnjm5699 3 года назад

    thank you

  • @Sk8erMorris
    @Sk8erMorris 4 года назад

    the classic "this means this" lol .. great tutorial makes me understand this Reference a lot more than just reading about it

  • @jonsdogg2400
    @jonsdogg2400 4 года назад

    You never know how many tries and attempts I did to phrase this out for RUclips to understand that I'm referring to this.keyword in coding

  • @herobrinehacks2321
    @herobrinehacks2321 3 года назад

    Cool video, but what does it means when we call a method like this one: fun(this); what 'this' keyword means in this case?

  • @maryyamsiddiqa3859
    @maryyamsiddiqa3859 2 года назад

    why do we have to declaren the variables globaly? can't we just declare in the parameter list?

  • @khuramali2980
    @khuramali2980 5 лет назад

    Can you please make a video on associations? It could save me!!!

  • @arischvaranpuvanesvaran8875
    @arischvaranpuvanesvaran8875 3 года назад

    Thank you!!!

  • @gaycat599
    @gaycat599 4 года назад

    great video!

  • @pbetftdi
    @pbetftdi 2 года назад

    Still quite confused. Why even name variables the same name and go through all the confusion of this (other than it will be a few questions on the certification exam) when its so much easier, clearer, and not frustratingly confusing to name the variable different names?

  • @seenathgooding181
    @seenathgooding181 2 года назад

    thanks!

  • @sarthakjoshi21
    @sarthakjoshi21 2 года назад

    when we use this.a and this.b and remove static bcuse we can't do ith static variable t.a and t.b

  • @edgarwideman737
    @edgarwideman737 4 года назад

    I skipped University, bought about $50 worth Udemy courses when on sale, and watched youtube for about a month. I'm now a full-time android app developer with zero College loans to pay off and doing my job 3 years sooner than had I gone to school!

    • @davidstark2973
      @davidstark2973 4 года назад

      Could you suggest me some good udemy courses regarding programming languages and android development??? It's really difficult to choose the right ones...

    • @edgarwideman737
      @edgarwideman737 4 года назад

      @@davidstark2973 Don't take my word on this as "the best way to learn", everyone has there own way of learning so if you learn online you have the freedom to choose your professor. I found this android java course to be just what I needed and followed along perfectly with the video speed at about 1.5X www.udemy.com/share/101Wq8BEEceF5UQ3o=/ also before that I did the A+ 901 and 902 computer course which was also amazing!

  • @mzamomahaeng268
    @mzamomahaeng268 3 года назад

    this was a great video 👍 see what I did there.Thank you man

  • @binsunaid
    @binsunaid 2 года назад

    Hello Alex hope you are ok,
    Thank you for the Java videos, I have learned a lot. I am trying to install eclipse but cant. The installation is very slow
    and after a while it gives a message it did not install. I tried different connection, but nothing. Appreciate your support.

  • @caseyj1144
    @caseyj1144 4 года назад

    So the bottom soup in the allocation moves first into the Set data and then that puts it also into the Class as a whole? (Arrows would help in the future).
    Also, is the purpose so that the rest of the class methods have access to the food and size data? (I’m so New I’ve just been writing print within the method taking the parameters so that I can just reuse the names there without issue. Or sending them into another print method directly)

  • @dickhea334342545
    @dickhea334342545 2 года назад

    Curious, how did you make the instance of the class (object) without using a constructor in your code?

  • @360dom360
    @360dom360 3 года назад

    Couldn't you just have one variable be "setFood" and then have the setter statement say "food = setFood" to keep it clear?

  • @Applestaffman
    @Applestaffman 2 года назад

    why static cannot be used after the keyword this in this case?

  • @russellandrady
    @russellandrady Год назад

    Absolutely amazing.

  • @mynamesjeff9290
    @mynamesjeff9290 3 года назад

    I feel like if it were callled 'that' it would make more sense

  • @coleeckerman1390
    @coleeckerman1390 4 года назад +1

    THIS!

  • @paulburger330
    @paulburger330 4 года назад

    8:30 where the penny dropped for me
    (Edited) great tutorial btw

  • @lukemalonis8533
    @lukemalonis8533 4 года назад

    Dayummmm I understood this so fast. You are somehow better than all of the Indian guys on here 😂.

  • @victorpinasarnault9135
    @victorpinasarnault9135 2 года назад

    Liked and subscribed.

  • @jonahosband4534
    @jonahosband4534 3 года назад

    Could someone explain why the compiler is confused when in the method he created a new instance of the object then used t.a and t.b? I understand most of this vid but that example is strange because I would assume that the values would be assigned correctly since you are using the instance and dot operator

  • @sabertoothwallaby2937
    @sabertoothwallaby2937 3 года назад

    why do we use eclipse to write Java on?

  • @aadityagadhvi4236
    @aadityagadhvi4236 4 года назад

    So is it just like the __init__ method in python

  • @benjamincox9762
    @benjamincox9762 4 года назад

    How do you set your settings so that when you create a new java project, it automatically goes into your package explorer? I have to extract my java projects manually and it would be just so much easier and less time consuming if I didn’t have to do that anymore.