Getters and Setters Java Tutorial #84

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

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

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

    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

  • @magicvibrations5180
    @magicvibrations5180 5 лет назад +420

    My professor is useless. Thank you for this video, I needed it.

    • @4seth
      @4seth 3 года назад +28

      It's not always that they are useless, but the curriculum puts constraints on how effective of teachers they can be.

    •  3 года назад +14

      Exactly. My course is teaching me the same thing in 4 hours and I don't get it at the end of it plus feeling like a stupid. And he literally teach perfectly in 15 minutes. I don't know what else to say.

    • @thejamericanexperience2757
      @thejamericanexperience2757 3 года назад +14

      University is mainly for profit.

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

      @@thejamericanexperience2757 Depends on the university

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

      wouldn't agree more 😤

  • @soar01
    @soar01 5 лет назад +123

    Alex, please continue doing these tutorials. It helps me, and I'm sure a lot of others who want to extend their knowledge of Java.

  • @melodyosterholm3515
    @melodyosterholm3515 5 лет назад +77

    This man has just saved my schooling career!!

  • @jj-fe6hz
    @jj-fe6hz 3 года назад +2

    bruh, this video explained "this' better than any of the other 10-20min videos out there specifically trying to explain "this". THANK YOU

  • @Sir_Sammi
    @Sir_Sammi 5 лет назад +303

    Just did my java final earlier this week, definitely would of failed without your videos, thanks for your good work!

    • @SubZeRoy9
      @SubZeRoy9 3 года назад +17

      Nice I did mine Monday. Alot better now that it's summer I feel like I'm going to learn alot more just doing my own stuff and making projects for fun. School has a way of sucking all the fun out of anything interesting. Lol

    • @eliasmore7500
      @eliasmore7500 2 года назад +5

      Would've

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

      What kind of example questions did you encounter? Could you show us 1 or 2? Just to see what they ask in a java exam =D

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

      its not work its a work of art you troll

  • @minhhuynh2646
    @minhhuynh2646 5 лет назад +48

    Thank you! I have been writing get, set for a month without knowing why and when to use lol. Thanks a lot

  • @teachernewteacher1944
    @teachernewteacher1944 5 лет назад +47

    Alex. You are so humble person. Great and easy explanations of all topics. Please give more exsamples for oop concepts, array, collections. (You may give exsamples from real life). I recommend you to my friends they are very glad to watch you. Respect. You do such a great job.

  • @christianek.963
    @christianek.963 3 года назад +5

    I have recently started to learn Java and when I saw him get excited by generating the getters and setters my heart skipped a beatt cause I'm used to that, but it's so cute when you see people get excited about things you already know or have. It makes me think of elderly who are surprised by all the new technologies

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

      He already knew about it lol. He was just excited to tell us about it because its a great shortcut for beginners, not because he just learned it.

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

    You are like a magician that casts a spell, and all of a sudden the fog is going away, making room for the sun to shine.
    My mind felt like clearing up while I was watching this awesome video of yours.
    There are many Java-related tutorial videos out there, but none of them have this talent to explain in such a clear and comprehensible way. Bonus points for your charismatic and charming charisma 😊😊

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

    omg 13:01 the short cut is very useful ! Thank you Alex !!! Right click -->Source-->Generate Getters and Setters

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

    @Alex Lee All schools should have to pay a small dividend to you for students that passed their classes, but only did so because they watched your videos. You are a Java programming wizard in my book my man! Thanks for also stepping through how the compiler runs through the code. That really helped hit it home and tied it all together.

  • @ShadyChild12
    @ShadyChild12 4 года назад +39

    Getters/setters also allow you to perform actions on the input before setting/getting the variable, for example, you could change the setName to
    this.name = name.toUpperCase();
    This will set the variable to all caps. Getters/setters are very powerful when used correctly!

    • @matheusvarani303
      @matheusvarani303 8 месяцев назад

      cool, didnt know we could use .toUpperCase() with set, thankss

  • @ВладимирЧескидов
    @ВладимирЧескидов 2 года назад

    Great! The author decided from the very beginning to teach programmers what everyone has been trying to unlearn for about 15 years now: write accessor methods.

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

    Hello Alex. My name is Freeman, from Nigeria. Just to let you know that your videos made great impact to my learning java. Thank you so much.

  • @Imluisx
    @Imluisx 5 лет назад +12

    You make java extremely simple without over complicating it! Appreciate the videos man!

  • @dankBenk
    @dankBenk 8 месяцев назад

    You explained in 5 minutes what my professor couldn’t explain in 2 weeks, well done!

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

    When my professor introduced our getters/setters lecture, I thought this was about to be a deep lecture in OOP theory. Come to learn, it was all about creating instance methods to return the state of an object or implement some action on it's state within a client program. I wanted to leave after 5 minutes. I'll say though, I'm glad you've gone over this and I think your video is about the right amount of time for any student to understand these fundamental concepts.

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

    I've watched hours of tutorials on RUclips but this one just clicked with me! Great job, good teacher 👍

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

    not that I didn't understand what setters and getters are for but I'm glad your youtube channel exists cause my java II professor barely teaches like this at all. Just gives us reading assignments and you basically gotta teach yourself the material

  • @karaunderwood5821
    @karaunderwood5821 3 года назад +6

    Alex, your videos are incredibly helpful. You have a real knack for explaining confusing concepts in an extremely understandable and simple way. Thank you!

  • @bertjan1297
    @bertjan1297 4 года назад +2

    6:22 It doesn't confuse the computer (or rather the compiler). It simply sets the local variable 'name' to itself. By doing this it doesn't achieve the goal you want because the name of the scope variable and object variable are the same and the latest defined variable in the scope will always be used.
    On another note:
    Getters and setters are a lot of boilerplate code. Even for beginners I would suggest using something the like Lombok extension / plugin for Java. Creating something like the Account class in this video can then be done with:
    @Data
    public class Account {
    private String name;
    private int age;
    }
    That piece of code will have getters and setters and even equalization that is desired. At compile time it will be converted to normal Java code. Or if that is too much you can also use
    public class Account {
    @Getter @Setter
    private String name;
    @Getter @Setter
    private int age;
    }

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

    I havent seen any other tutorials that explain step by step of what you are doing and why. Thank you!! Youre the besttt

  • @NEnigma777
    @NEnigma777 7 месяцев назад

    You explained more in the first minute than my damn class and professor did this whole semester. Thank you!

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

    Hey ! Alex, I am from India. This comment is to thanks you "This video help me to understand getter & setters easily" , also your bonus tip is just like you nailed it.

  • @DivingChipmunk
    @DivingChipmunk 5 лет назад +32

    Just learned this in my AP comp sci course, nice vid

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

    Without your video on how to learn java in 17 minutes I would never had picked up Java TY!

  • @khareek2453
    @khareek2453 5 лет назад +7

    Perfect explanations, easy to follow along. I can watch several of your videos and not get bored for even a second ❤

  • @Jerry-dq1zz
    @Jerry-dq1zz 3 года назад +1

    I'm currently taking this course and to have further knowledge, I watch your free videos. Thank you and please do create more!

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

    I have a test next week and this video really helped me ty!

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

    I learned all of this through CS Awesome, but your vids had definitely clarified the details of java code and I thank you so much for it

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

    I have never been to college so don't know how they teach java. But This guy did a great job for me !

  • @uwaishakim123
    @uwaishakim123 4 года назад +2

    My finals is in few hours and this definitely helped me understand on why, where and when to use getter and setter. Thank you so much Sir 😭🙏🏻✨

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

    your videos are really helping me get through my university programming classes, thank you.

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

    I'm so grateful for all of Alex's YT videos haha

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

    i was so confused about the 'this' parameter but now i know ..........thank you alex for the precise info...love love

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

    i cant believe my course didn't have getters and setters explained and this is such a crucial topic!

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

    You are awesome! i am studying CL and Java is my core subject atm and you really do make studying for my assignments easier! Thanks!

  • @anees3934
    @anees3934 5 лет назад +14

    Such an hohroble person: you have a very special way to deliver your lessons:

  • @KrigRaseri
    @KrigRaseri 2 года назад +2

    The last tip is a poggers moment.

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

    13:18
    If you are using NetBeans click (Alt + Ins) >> If you are using a LapTop like me, you will find (Ins) in the numbers pad on your right-hand side.

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

    You don't know how much this has cleared for me

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

    You are the organic chemistry tutor of programming. Thank you!

  • @asthetikleo
    @asthetikleo 6 месяцев назад

    Alex is literally in a class of his own at teaching Java

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

    you can also generate getters and setters automatically in eclipse by doing:
    Source --> Generate Getters and Setters
    picking the variables then 'Generate' (you can also choose modifiers) and it will generate those for you

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

    You are a live saviour, legit my teacher can't explain for the life of him

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

    Superb I couldn't understand this when my lecturer taught me but after seeing yours I can

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

    I LOVE ALL YOUR VIDEOS! Thanks a lot

  • @ZaRahula
    @ZaRahula 4 года назад +2

    I'm starting java this semester and I'm trying to wrap my head around OOP. Thank you sooo much So helpful!

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

    Thank you very much. I was thinking it's gonna be very hard, but you're teaching very easy.

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

    That trick using Eclipse to generate the getters and setters was really neat!! Thank you!

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

    You are amazing. I thank God that you made this tutorial because not gonna lie, I need you in my life 💯

  • @brotpapa2250
    @brotpapa2250 2 года назад +1

    Man, now everything makes sense...thank you so much for making these videos :)

  • @JTBanks
    @JTBanks 5 лет назад +3

    Thanks once again Alex, appreciate all you do for us here on RUclips. Very helpful! :)

  • @SurajKumar-dz3zo
    @SurajKumar-dz3zo 4 года назад

    Thanks a lot ! I actually tried finding a video explaining this keyword and getter and setter for over 4 hours, and I found this now. You actually make concepts a lot easier to understand. And thanks again, I needed this for an assignment.

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

    Damn, you explain better than my college techer, what a legend. Keep it up man

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

    that shortcut at the end was absolutely insane lol thank you so much

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

    One of my favorite videos you've ever done. Thank you, Alex!!

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

    Alex! thank you; i finally understand setters and getters after watching this :)

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

    My professor didnt explain this to us, but now i have u.

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

    Dude Thank you so muchhhh for create these videos 🥺❤️❤️ They don't teach us anything at uni . Your videos helped me a lot .Thank you wish you the bests 🙏🏻

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

    You are the master of java. I really love your explanation at the end. Love from INDIA

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

    million thanks, Alex. Your tuts have simplified my study life in Java.

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

    Couldn't understand the concept but gosh Thank You for the simple and clear explanation!!!

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

    My job depends on my java understandings.. I'm lucky I have your videos now..! Thankyou ^_^

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

    Alex!!! Thanks so much for all your videos! I've just started my Java course and your video's really help me out a lot!

  • @lonewolf3623
    @lonewolf3623 5 лет назад +21

    Can you make a tutorial on abstract classes and interfaces

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

    Okay since today you're my favorite kind person on earth 💐

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

    Finally, someone explained it to me. Thanks, Alex

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

    the trick in the end was amazing

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

    Hey, just wanna say you're really awesome! Your tutorial really helps and its very easy to understand. My professor's teaching is nowhere near your teaching. I hope you continue to make these videos, thank you so much for these!

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

    bro when I close my eyes that's my world without you bro :')

  • @armigeddon4451
    @armigeddon4451 5 лет назад +2

    THANK YOU SO MUCH! you're so much better than my current professor in university (no offense to him but I got so frustrated that I didn't get what he said because he keeps over complicating and over explaining his lessons that I got confused) but this is all the lesson had to say ;-;

  • @b.m.1022
    @b.m.1022 2 года назад

    Holy crap I'm glad I stuck around for the bonus tip! thanks for the video Alex

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

    Great video again!! 😊👍 But i wonder if you, in the future can make seperate class files for the methods etc...since that is actually how the program has to be stuctured. But by all means, love you videos!!❤

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

    Thanks a lot man! You're the best. I finally got this, been struggling with it for quite a while.

  • @Eli-tb2vd
    @Eli-tb2vd 3 года назад +1

    the last tip was like "aaaaaaaaaaaa....!!" thank you for sharing.

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

    ur videos + codegym = junior
    thank u

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

    not related to java but I LOVE LISTENING YOUR VIDEOS BECAUSE OF YOUR KEYBOARD TOO SO RELAXING (KEYBOARD ASMR)

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

    Im second year college BSIT i learned alot in your videos please make more videos...

  • @9chickenwingz
    @9chickenwingz 2 года назад

    Alex, you’re the teacher we needed! 👏🏽

  • @rosemarynyambura-n5n
    @rosemarynyambura-n5n Год назад

    am very very much impressed by this am 18 yrs of age thumb up for good work thanks a lo

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

    Thanks for this very helpful. PS - You only need to type syso + Ctrl+Space to save a few keystrokes each time.

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

    Thanks for this! I've been able to complete my Performance Task. I appreciate you sir!

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

    Now that I found the best explanation 👌 Thank you Alex so much 🙌🏼

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

    Thank you so much for this video! I am trying to learn java in my freetime and for some reason, I couldn't quite understand what's it about with getters and setters. This video helped a lot!

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

    You are genius! You just made my 2 hours lecture into a 14 mins video.

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

    No exaggeration, you really helped me a lot🤗

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

    Haha, I've gone through this before but I actually got it this time. Actually was watching more to verify this time.
    Before, I had the getter backwards, thinking that getter got the value from user then passed it to the setter... which didn't make much sense haha

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

    **Alex -- this was so much easier to follow than my own instructor, thank you! The only thing I'd like is a little slower on the ending code walk through and if you had a highlighter pointer to see where you are talking about, that would be even better! Really great though!
    ** Does anyone have the shortcut or plugin for Notepad ++ for the System.out.println(); ? I tried installing the QuickText plugin but I can't get it to work. We will be moving over to Eclipse soon, but we are in Notepad++ right now and it's so annoying to have to keep writing out the print method.

  • @Fnaf-vh9cs
    @Fnaf-vh9cs 3 года назад

    I remember when you was so less subscribers, I made you a few compliments back then and I wanted to join the Facebook page but I took to much time so you can accept me so , I deleted my request anyways man the reason I put another comment is that you really help people around with this videos , Alex be safe man and thanks for this videos very helpful now that I have a clue about java, now is coming together the code.

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

    You are an actual lifesaver

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

    when making the set and get methods, you could name the method anything and it would do the exact same thing, if the details of what the method does stays the same...
    i guess its just really good practice to do so
    and its really convenient
    also btw ur tutorial is great!

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

    The extra tip at the end was awesome.

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

    I'm grateful I found this channel. Thank you very much sir!
    I'll be more happy if you make a video for "Different Errors in Java programming and how to fix them" and "Shortcuts and the environment of Eclipse" (cause we can't edit in Photoshop without knowing it's tools right?)
    Thank you again sirr!

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

    big like for the bonus tip. That saves sooooo much time. Thanks! 🙏🏽🙏🏽🙏🏽

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

    Alex I have watched many videos however you are the best !

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

    I cried when you presented the sourcing option for setter and getters loooool, JDKs ftw!

  • @11suryanshtomar91
    @11suryanshtomar91 3 года назад +1

    thanks bro it helped me a lot to pass my exam thanks bro

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

    Thanks for really sharing , good work with us, am really appreciating the good effort you are putting in. Honestly I have understood the topic well.
    Thank you very much Lee