Encapsulation in Java Tutorial #83

Sdílet
Vložit
  • čas přidán 1. 01. 2020
  • $1,000 OFF ANY Springboard Tech Bootcamps with my code ALEXLEE. See if you qualify for the JOB GUARANTEE! 👉 bit.ly/3HX970h
    Encapsulation in Java is accessing private variables using methods. These are also known as setters and getters!
    I hope you enjoyed this video on how to use encapsulation in java :) -
    Full Java Tutorial For Beginners Playlist: • Full Java Course by Al...
    Free Tips: bit.ly/3U6HXcb
    Disclosure: The Springboard link provided is linked to my affiliate account & supports the channel.
    ~
    Alex Lee

Komentáře • 293

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

    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

  • @alexanderderictapalla58
    @alexanderderictapalla58 Před 4 lety +241

    You're a magician. You made every topics in Java understandable. Like wow. Just wow. Thank you very much!

  • @latedeveloper7836
    @latedeveloper7836 Před 3 lety +90

    Yet another excellent explanation. Timestamps below for anyone who needs them:
    1:00 Definition of encapsulation
    3:03 How to use encapsulation with getters and setters
    3:17 What static means
    5:19 The point of encapsulation - extracting variables from the user
    9:22 Summary of what encapsulation is

  • @mrblobby1841
    @mrblobby1841 Před 2 lety +28

    Useful to note: most setter methods would include validation logic and checks. For example, check that age is greater than X for a student.

  • @mrpickles1
    @mrpickles1 Před 3 lety +31

    I'll eat my shirt if there's anyone out there who can explain java better than alex
    My college lectures are incomprehensible and i fall asleep 9/10 times.

    • @adamdreier
      @adamdreier Před 3 lety +3

      That’s why I didn’t go to college hahaha, some dude on CZcams explaining it better than a University lmao 🤣

  • @acelyaerdogan2222
    @acelyaerdogan2222 Před 4 lety +4

    Wow you make it seem so simple and understandable - super grateful to have found you; your videos would literally be how I will pass my end of year Java exam. Thank you! Looking out for your videos - keep striving!

  • @ndyer6005
    @ndyer6005 Před 3 lety +4

    You explained so clearly and precisely what my instructor took 2 hours explaining. I also enjoying copy-coding with you and then modifying my methods and variables for practice.

  • @java_tech_guru
    @java_tech_guru Před rokem +2

    When we create a class with private members. What we are actually trying to do is create a user defined data structure. It helps us to store the data privately. It prevents direct access.

  • @Nanis-World
    @Nanis-World Před 2 lety +12

    Alex, you've helped me get through all of the Java courses for my computer science degree. Thank you so much for the time you've put into making these videos and for helping me understand what my "teachers" are getting paid to do but failed miserably at!! 😊

  • @luiso3482
    @luiso3482 Před 4 lety +4

    Alex, you rock! You have the gift of teaching. Keep it up and thank you for spreading your knowledge.

  • @mariyaqureshi6800
    @mariyaqureshi6800 Před 4 lety +6

    I wish I found this channel when I was in my java class. You explain it so clearly!

  • @koushikpaul5957
    @koushikpaul5957 Před 3 lety +1

    I had a lot of difficulty with this at first, you made this a lot simpler than I thought it was. Thanks!

  • @RakijaČardaklija
    @RakijaČardaklija Před 3 lety +1

    The best short definition of encapsulation and fantastic explanation. Great video Alex.

  • @tanjimashraf803
    @tanjimashraf803 Před 4 lety +1

    You make the complicated topics so easy to understand. Thank you so much.

  • @TomJMumford
    @TomJMumford Před 4 lety +2

    Hey Alex, Thanks so much for your videos. They're really helpful!

  • @mariaolsson1458
    @mariaolsson1458 Před 3 lety +1

    This really made a difference to me. Now I know what I did have so much trouble to understand about Java, it was Encapsulation. And now Alex explained how it works. Thank you!

  • @AoDShotZz
    @AoDShotZz Před 2 lety +1

    You’re such a huge motivator! You make things possible to understand. Thank you

  • @troubledtom5250
    @troubledtom5250 Před 2 lety +1

    thanks i was trying to understand from that one programming book my teacher recommended to me but couldn't understand much except for the different classes bit ,so really glad i clicked on your video thanks alot man your a life saver.

  • @Nas_Vinspired
    @Nas_Vinspired Před 4 lety +1

    Thank you for the very helpful and easy to understand video content, man!

  • @joethompson8147
    @joethompson8147 Před 3 lety +10

    In IntelliJ you can right click in the Student.java class, choose "Generate", choose "getter" or "Setter" and IJ will write the methods for you.

  • @digby2263
    @digby2263 Před 2 lety

    Thankyou so much I was falling behind on our lessons this past few weeks and having a hard time on understanding how to use encapsulation, since I was ill of covid❤️

  • @asimenibhavya6423
    @asimenibhavya6423 Před 3 lety +1

    You just made my life very easy in learning and understanding java concepts! THANK YOU! (Y)

  • @batoolali3529
    @batoolali3529 Před rokem

    i am so thankful that your channel exist thank you for sharing your time and effort
    love the way you present the ideas

  • @supernovic99
    @supernovic99 Před rokem

    I'm currently preparing for the AP CSA on my own and your videos are literally the reason I'm confident for the exam. Thanks a lot!!!

  • @novalandinc.1345
    @novalandinc.1345 Před 3 lety

    Thank you Alex. You Made learning Encapsulation easier

  • @williamparker382
    @williamparker382 Před 4 lety +5

    This is awesome and so simply explained!

    • @mormsophen3238
      @mormsophen3238 Před 4 lety

      Yeah. It is too simple or maybe i already familiar with set and get

  • @megabubbles9478
    @megabubbles9478 Před 2 lety

    You teach in a very calm and peaceful manner it’s kinda relaxing to watch you teach

  • @mp7596
    @mp7596 Před 2 lety

    Alex, this was a great explanation. I am studying for an assessment for an entry-level job, so thank you

  • @moniashelli9502
    @moniashelli9502 Před 4 lety +1

    thank you for explaining this, i actually thought it was complicated

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

    you're a life saver man, wish you all the best😊😊

  • @Glennyates1025
    @Glennyates1025 Před rokem

    You have a gift. Very clear and enjoyable. Well done!

  • @albarsalan4173
    @albarsalan4173 Před 3 lety +1

    Thank you man for your great efforts. I believe you are one of the best on CZcams keep up the good work.

  • @heinrichwettin
    @heinrichwettin Před 4 lety

    great work on all of your explanations !

  • @naweedmohammadi7909
    @naweedmohammadi7909 Před 3 lety +1

    Your explanation was amazing Alex, the most understandable explanation ever keep it app bro

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

    precise and easy way to explain it, ty💯

  • @darrenjosiah9246
    @darrenjosiah9246 Před 2 lety +1

    3 weeks ago OOP was a foreign concept and I dreaded it. Now I'm mastering it and ready for an interview!

  • @delzyfire7209
    @delzyfire7209 Před 4 lety +19

    please keep do what you are doing.I'm learning soo much thanks to you

  • @mikebrown5142
    @mikebrown5142 Před rokem

    Awesome vid, your explanations are spot on. God bless!

  • @viniciusbrisotti9848
    @viniciusbrisotti9848 Před 4 lety

    Great explanation bro! You presented the concept in a very simple language

  • @spicebowl6325
    @spicebowl6325 Před 4 lety +6

    Thank you so much. Keep going.... 🙏

  • @rittenbrake1613
    @rittenbrake1613 Před 4 lety +1

    very clear Thanks Alex

  • @sunkistzerosugar
    @sunkistzerosugar Před 3 lety

    Currently in 2150 programming and my professors have been pretty iffy at explaining the terminology and what is actually going on but damn man you make this as clear as day.

  • @johnrodriguez6164
    @johnrodriguez6164 Před 4 lety

    Thank you, AWESOME Video! Very Helpful

  • @lahirudamianperera6255

    Thanks man ♥️java is in ur blood...I thought of giving up java....but ur way of teaching changed mee...thanks dude

  • @anvarbekziyodov
    @anvarbekziyodov Před 4 lety

    bunch of thanks Alex, you made my day

  • @danujagreru
    @danujagreru Před 4 lety

    keep going, dude. it's very simple to understand

  • @mempi9514
    @mempi9514 Před 2 lety

    Hi, you are really good explaining java material. I am grateful to have found you

  • @An_American_Boy
    @An_American_Boy Před 2 lety

    Arigato.
    You've done the work so easily that it had made difficult for others to do.

  • @anthonyakamook
    @anthonyakamook Před 2 lety +1

    Thank you, this made perfect sense for me!

  • @duongvuong8514
    @duongvuong8514 Před rokem

    OMG, what you said, I deeply felt it. I went through a whole semester without knowing what OOP is, got 50% on final but still ended up with a B. I swear, in that online class I did everything I could, look for all explaination both from online and from her but I still didn't get anything. Now it just came to me after 5 mins watching you lol. Thank you, thank you, thankyou!

  • @matthewmarchman8885
    @matthewmarchman8885 Před rokem

    Love how you explain these concepts 💯

  • @brandonbelcher1002
    @brandonbelcher1002 Před 2 lety

    Very concise and useful. Thanks so much!

  • @SSracer192
    @SSracer192 Před 3 lety

    Thanks Alex for creating these videos, keep it up!!

  • @mohammedsakib5
    @mohammedsakib5 Před 4 lety +1

    Hey man love your videos!!!

  • @Geminis3505
    @Geminis3505 Před 4 lety

    Thanks so much for this video!

  • @tjake7864
    @tjake7864 Před 3 lety

    Nice work Alex!

  • @pablofalco
    @pablofalco Před 3 lety

    Finally I get this...Thank you!

  • @bigunhettiarachchi853
    @bigunhettiarachchi853 Před 2 lety

    Man your videos are so great and to the point
    Plus, you’re excellent at explaining 😍🥰

  • @mehdimah2760
    @mehdimah2760 Před 4 lety +1

    Thank you Alex.

  • @MrAc3528
    @MrAc3528 Před 4 lety +27

    Hey Alex could you possibly make a video on the merge sort algorithm?
    You’re the best java teacher on CZcams and if you explained it I know for sure I would comprehend it. Thanks man.

    • @Monster33336
      @Monster33336 Před 4 lety

      Java is so hard you might need an expert for specifics.

    • @scholli99
      @scholli99 Před 4 lety

      @@Monster33336 youre making fun about java? Dude did you ever developed software professionelly ? Java is pretty complex language.

    • @Monster33336
      @Monster33336 Před 4 lety

      @@scholli99
      just that Java is a nightmare when working with real objects not just system.out.println

    • @shashankshetty5879
      @shashankshetty5879 Před 4 lety +8

      You both are making it hard for starters like me to learn the language . No problem if it is hard or complex I will learn 👀

  • @Pandaputih2000
    @Pandaputih2000 Před rokem

    I'm glad found this video. Learnt alot.. Thx

  • @starmehari2071
    @starmehari2071 Před 3 lety

    Thanks a lot Alex it is really helpful.

  • @benanikin4388
    @benanikin4388 Před 3 lety +1

    Bro you're a life saver! 10 mins of your content worth more than 2 hours with my professor

  • @le_travie7724
    @le_travie7724 Před 3 lety

    Annnnd subbed! You're way better at explaining this than my profs. Cheers m8

  • @Blackronin357
    @Blackronin357 Před 4 lety +3

    Really great tutorial, can't wait to see what else you have to teach. I was following along well enough and ran into a snag w/ the encapsulation between the two classes. I'm thinking its because I'm using a different IDE (intelliJ) that doesn't have the same robust options when it comes to creating a new class. Going to try with the IDE your using an see how it goes from there. Nonetheless, I still was able to understand what went where and why.

    • @Blackronin357
      @Blackronin357 Před 4 lety +1

      Ran the test code in Eclipse IDE and it went through as it should. Wondering what difference the IDE settings make? Only thing I can think of is that there was a confirmation request to run both classes in Eclipse where as it seems intelliJ only wants to run one. Wondering what it should be set as to allow both?

  • @samael5653
    @samael5653 Před 2 lety

    thanks of what you are doing i will maybe have the 99% more chanche to pass my exam... thank you Alex ! you're amazing!!!

  • @shenfdo8779
    @shenfdo8779 Před 3 lety

    Nice explanation Alex, and Thanks 😊

  • @beratkurt8084
    @beratkurt8084 Před 2 lety +1

    Very helpful for my final exams, apprecitaed sir.

  • @user-tk6vy2ec8u
    @user-tk6vy2ec8u Před 2 lety

    Really helped, thanks so much!

  • @tlo0542
    @tlo0542 Před 3 lety

    excellent explanation. Helped me alot. thank you.

  • @arhamsfunnymemes8156
    @arhamsfunnymemes8156 Před 3 lety

    nicely explained.Thanks

  • @darkhead612
    @darkhead612 Před 2 lety

    Thx for that shortcut!!

  • @HareKrishna15
    @HareKrishna15 Před 3 lety

    Happy new year you teach very well by the way

  • @bradtagegogona7076
    @bradtagegogona7076 Před 3 lety

    Loved the video

  • @raymakaveli
    @raymakaveli Před 4 lety

    awesome video my friend ! you're a smart dude

  • @harshasuresh4062
    @harshasuresh4062 Před rokem

    When I say you are a lifesaver, I mean it!!! Thank you Alex ❤

  • @Shaf23
    @Shaf23 Před 4 lety +2

    Can you make a video about composition next? Great content by the way, very helpful for me.

  • @rolfchristensen9026
    @rolfchristensen9026 Před 2 lety

    Great explanation. As always an excellent video :)

  • @hempoyofficial
    @hempoyofficial Před 2 lety

    Great! I've learned a lot.

  • @herbaltreatment396
    @herbaltreatment396 Před 3 lety

    Wooooooooo you are great Alex.

  • @tonynork7931
    @tonynork7931 Před 2 lety

    Great and simple explaining👍

  • @amnatariq711
    @amnatariq711 Před 3 lety

    Thanks the video is very helpful

  • @SureshramT
    @SureshramT Před 3 lety

    You are awesome 👏🏻. Thank you 🙏🏻

  • @tanveerahmad8455
    @tanveerahmad8455 Před 2 lety

    after many lecture watched finally u satisfy me ->🥰Thanks Alex

  • @maxd7228
    @maxd7228 Před 4 lety +1

    Also setters can be used for validating the data type. If you send a int to a String your program crashes but using the setters you can catch that and throw an exception or perform additional actions on the passed value to reformat before storing the value.
    Great vid as always.

    • @welltypedwitch
      @welltypedwitch Před 4 lety

      That's not how java works, but for sonethibg like JS or Python, thos may be quite useful. Java is statically typed, so your compiler will conplain, if you try to pass an int to a function that expects a string

  • @rachamallidorasrivignesh4499

    tq lee its very nice explanation.

  • @lihlemgugudo664
    @lihlemgugudo664 Před 3 lety

    thank you so much!!!!!! your videos are very helpful

  • @jacobfrank6838
    @jacobfrank6838 Před 3 lety

    Thank you so much for it.

  • @benitaezeoke1568
    @benitaezeoke1568 Před rokem

    THANK YOU SO VERY MUCH !
    I'M GRATEFUL

  • @igorpetkovic4979
    @igorpetkovic4979 Před 4 lety

    Excellent video

  • @oopsiedoopsie861
    @oopsiedoopsie861 Před 4 lety +1

    Hey Alex, could you make a video on making GUI? Thanks for the easy-to-understand java videos!

  • @honeybeedays6392
    @honeybeedays6392 Před rokem

    Thank you Alex ❤

  • @AlexOlivares471
    @AlexOlivares471 Před 4 lety +5

    Damn dude, great explanation. Now I might pass my Java exam tomorrow, thanks!

  • @namratapai4650
    @namratapai4650 Před 3 lety +1

    Thanks a lot :) this is so goooddd :)

  • @bhanupriyatham668
    @bhanupriyatham668 Před 3 lety

    simply awesome man .......... love from india

  • @joethompson8147
    @joethompson8147 Před 3 lety +20

    5:30 "The point of encapsulation is to abstract the variables from the user to make it easier to use the object."

  • @wiktorsobczyk6547
    @wiktorsobczyk6547 Před 4 lety

    best teacher ever

  • @bozhidarkn
    @bozhidarkn Před rokem

    My man! These are some of the best explanations I have found regarding programing. Not just Java but Programing in general.
    Please share a PayPal or Patreon or other page where I can support you directly. I will not be purchasing the linked products or the full course (which I am completely sure is wort every penny and I will most definitely recommend to any folks looking to learn Java) but I still want to buy you a drink the least!

  • @yazuka2023
    @yazuka2023 Před 2 lety +1

    thank you god bless u this is really helpful

  • @ahmedelsleet8542
    @ahmedelsleet8542 Před rokem

    carrying me in my java course! thank you