Java Tutorial for Beginners – 31 – Getters and Setters

///Java Tutorial for Beginners – 31 – Getters and Setters

Java Tutorial for Beginners – 31 – Getters and Setters

FavoriteLoadingAdd to favorites

In this tutorial we will discuss getters and setters and encapsulating your variables.

source

Java468x60
By |2020-02-03T01:32:58+00:00February 3rd, 2020|Java Video Tutorials|49 Comments

49 Comments

  1. Ko_ Pyae_Thaw February 3, 2020 at 1:33 am - Reply

    All Clear about Set / Get Method

  2. Epoch plus5 February 3, 2020 at 1:33 am - Reply

    EJ Media are you still there?

  3. xBrainZy February 3, 2020 at 1:33 am - Reply

    I don't understand

    this. height = x;

    What's the use of 'this'

  4. crazyx3s February 3, 2020 at 1:33 am - Reply

    so basically in summary:

    imagine if we have hundreds of methods
    and we need to change a value of a variable many months later
    but we forget the rules or conditions of a certain variable
    thats why we make variables private
    so only through the public methods: through the setter we can change a value, with the condition,
    and through the getter , we simply just return the value.

    Thank you this makes it so much clearer πŸ™‚

  5. Francis Lenard Samonte February 3, 2020 at 1:33 am - Reply

    Great explanation, man. I had a hard time understanding this concept with how my professor teaches. You helped a lot, lol

  6. dapianna23 February 3, 2020 at 1:33 am - Reply

    I'm currently taking APCS A and you're a godsend. I'm actually understanding things for the first time. Thank you!

  7. Running Codes February 3, 2020 at 1:33 am - Reply

    why not return this.height;

  8. somethingsomethingnickname February 3, 2020 at 1:33 am - Reply

    making content relatable by using orcs noice……..but that still HERESY!

  9. Lentor Marais February 3, 2020 at 1:33 am - Reply

    Hey man firstly I must thank you for your lessons on youtube, it is of great assistance understanding the various aspects needed to be understood. I must ask you however to please not cut you videos so short, at times (speaking over the course of the videos published) some aspects dont work, and on closer inspection its due to the cut of the video that either leaves out bits of what you have done… It can be highly frustrating at times. Back to the positive, big ups for opening yourself up to the big bad world, i love the fact that pple are mature and leaving comments that are tasteful and hopefully provide you feedback that you can take a learn from. I look forward to more tutorials that you may post

  10. hamza hayd February 3, 2020 at 1:33 am - Reply

    basically you made everything so easy.

  11. Blake Harrison February 3, 2020 at 1:33 am - Reply

    Thanks man, this tutorial is legendary

  12. Tarik V February 3, 2020 at 1:33 am - Reply

    1 minute in and your video has already helped me immensely. Thank you so very much

  13. Joseph Gagnon February 3, 2020 at 1:33 am - Reply

    Great simple and clear explanation! πŸ™‚

  14. Maksym Karunos February 3, 2020 at 1:33 am - Reply

    Guys, I `ve got a problem, the programm does not allow me to to put key-work "static" to the main method since it does not go along with "setHeight'. Help please

  15. Vladimir Susanu February 3, 2020 at 1:33 am - Reply

    Thank you

  16. Satoshi Nakamoto February 3, 2020 at 1:33 am - Reply

    thanks

  17. Ezinne Osuagwu February 3, 2020 at 1:33 am - Reply

    I have never really understood the use of getters and setters. I have battled with these concepts for a long time! You explained it so simply. Thank you so much! You are awesome!

  18. Thomas Linssen February 3, 2020 at 1:33 am - Reply

    I allready knew and used getters and setters, but i never thought about protecting your code like that, with those if statements. Great explanation, thank you.

  19. anass lyan February 3, 2020 at 1:33 am - Reply

    Great explanation, I just have a question, so if we are going to use setters to initialize the instances variable of the class, why do we need a user defined contractors with parameters that will have no control on the user input to initialize the instance variable?

  20. owningyourfinances February 3, 2020 at 1:33 am - Reply

    THANK YOU!!! You are DA MAN!!

    So I'm in this online class to learn Java (scratches head), now I know that I can just get youtube/EJ Media and learn it better.

  21. Unlim ited February 3, 2020 at 1:33 am - Reply

    A setter can only works if we dont use a constructor if im getting this right , because if we use a constactor we have to declare the values of the object in the parenthesis and in this case the setter is not called and is unable to check the values? and if im wrong how can we declare a new object and have it getting the values in parenthesis from a setter ?

  22. umair bin ali February 3, 2020 at 1:33 am - Reply

    really i em actually an IT student and along period i get to know what the getters and setters actually work thanks

  23. Cable February 3, 2020 at 1:33 am - Reply

    Some good ass stuff.

  24. Ibtisam Abdo February 3, 2020 at 1:33 am - Reply

    Excellent video. Thank you sir.

  25. Evan Chesterman February 3, 2020 at 1:33 am - Reply

    Great video

  26. Faijul Amin February 3, 2020 at 1:33 am - Reply

    Thanks, You just saved my day

  27. Free Stock February 3, 2020 at 1:33 am - Reply

    im having hardtime since ive finished 29 videos…

  28. john onocheta February 3, 2020 at 1:33 am - Reply

    no doubt you are a great teacher

  29. Ammar Sadeq February 3, 2020 at 1:33 am - Reply

    what happened to all your old work. they disappeared since a couple of videos

  30. Jacob Tran February 3, 2020 at 1:33 am - Reply

    this stuff is either confusing and not easy to grip or im just stupid. . .

  31. Yo Han February 3, 2020 at 1:33 am - Reply

    I really like how you go step by step on where the value goes. That was needed because it was getting hard for me to understand what was going on when I was studying in my uni. I needed some kind of visual mapping

  32. Michael Yang February 3, 2020 at 1:33 am - Reply

    holy shit this helped me with my project ty brah.

  33. Harry C February 3, 2020 at 1:33 am - Reply

    That was a beautiful example that i understood well! Thank you.

  34. James Whyte February 3, 2020 at 1:33 am - Reply

    You are truly the best I've seen on youtube at explanating Java concepts.

  35. Aris Amatore February 3, 2020 at 1:33 am - Reply

    im just trying to understand the getters and setters and im looking at as many explanations for this and why its needed, and this example with orcs ,and that they dont fit in to the cave thing made everything clear now.

  36. Anamika Ahmed February 3, 2020 at 1:33 am - Reply

    Short and simple..thank you for such a clear explanation πŸ™‚

  37. qazzy February 3, 2020 at 1:33 am - Reply

    Great tutorial and great example. Thanks man.

  38. Abdullahi Ahmed February 3, 2020 at 1:33 am - Reply

    Absolutely simple, intuitive and lucid.

  39. Pedro Gorilla February 3, 2020 at 1:33 am - Reply

    Thanks!

  40. Maerk Forbes February 3, 2020 at 1:33 am - Reply

    great video. thank you

  41. Jerome Macarilao February 3, 2020 at 1:33 am - Reply

    what if the value being change is String…how to set it in if else statement

  42. Aminuddin Basir February 3, 2020 at 1:33 am - Reply

    Hey @EJ Media, is this accessor and mutator? It seem like it is. Just need confirmation. Nice tutorial.

  43. Astro Boyq February 3, 2020 at 1:33 am - Reply

    thank you very much.

  44. Ralph Ng February 3, 2020 at 1:33 am - Reply

    Hi EJ, thanks for sharing the video. Any where I can get the code for expansion.java?

  45. Ramadan Mohamed February 3, 2020 at 1:33 am - Reply

    That really helps, thank you πŸ™‚

  46. Junaid Safdar February 3, 2020 at 1:33 am - Reply

    great job

  47. Nejat Sultan February 3, 2020 at 1:33 am - Reply

    hey Β how do u run Β orc 1 and orc 2 objects at the same time…is that possible to create two objects for one class..

  48. Gagan Johal February 3, 2020 at 1:33 am - Reply

    Amazing analogy

  49. Ryan February 3, 2020 at 1:33 am - Reply

    Larry, keep your Orcs at 9. Love it, lol

Leave A Comment

*