Learn Java Tutorial for Beginners, Part 15: Getters and Return Values

///Learn Java Tutorial for Beginners, Part 15: Getters and Return Values

Learn Java Tutorial for Beginners, Part 15: Getters and Return Values

FavoriteLoadingAdd to favorites

Get complete courses at
This tutorial shows you how to create “get” methods for your Java classes, and I’ll also show you how to return values from methods in general.

source

Java468x60
By |2019-11-06T23:46:49+00:00November 6th, 2019|Java Video Tutorials|21 Comments

21 Comments

  1. jamaraquai November 6, 2019 at 11:46 pm - Reply

    I just wanted to say, that I've tried learning computer programming (both C++ and Java) from a number of other places (Khan Academy – useless, SoloLearn – usless, CodeAcademy – useless, text books – better than the online options, but still lacking), and your lessons are the best I've found by far. For the first time, I'm actually understanding the why's and how's behind the language, and seeing the concepts applied in real-time as they're explained makes such a huge difference! I cannot tell you how thankful I am to have stumbled across your tutorials, and I can't wait to jump into other programming languages, as well. Thank you again!

  2. Jakonate November 6, 2019 at 11:46 pm - Reply

    what is the difference between

    System.out.println(person1.name)

    and

    System.out.println(person1.getAge())

  3. kosmox November 6, 2019 at 11:46 pm - Reply

    I can't believe how much of an animal is our brain ( we ). Like, yea sure, when we understand this programming it's totally easy for us and seems logical, but the point is, if it's so easy, than why don't we get it instantly?

    Our brains are logical machines right?

    No, our brain haves to create new connections to create the illusion of logic.. that's so sick. It's like our brain is a powerful VR module which allows us to perviece this world as we do. Even counting, 2+2, has be to learned. It's not obvious for someone who gets to know math for the first time. SICK!!!

  4. Andrew Lim Zhe Long November 6, 2019 at 11:46 pm - Reply

    Thank you so much! You teach extremely well!

  5. Wolfferoni November 6, 2019 at 11:46 pm - Reply

    It took me a while to get this. I mean, watching and following along in a tutorial is one thing but trying to do it from scratch is another. That's when the real learning happens. I highly recommend people to make another class and try to replicate John's code but with a different class, objects, variables etc. and try not to look at his code, try to just do it yourself. I made a class called Animal instead and though it took some time to figure out, I completely understand now.

  6. Shar Love November 6, 2019 at 11:46 pm - Reply

    YOU ARE AMAZING!!! Thank you for your videos!!!

  7. Kazimierz Garshin November 6, 2019 at 11:46 pm - Reply

    I hope you are making loads of money with your tutorials. They are terrific.

  8. sad kid November 6, 2019 at 11:46 pm - Reply

    You make such a great vids mate. I wonder if you ever drink some warter 😀 ?
    Cheers from Poland <3

  9. Steven Barnes November 6, 2019 at 11:46 pm - Reply

    You are the creator haha

  10. Stephen Collins November 6, 2019 at 11:46 pm - Reply

    This is an awesome video series! I am really getting ahead in my computer science class. Thank you.

  11. Differential Equations November 6, 2019 at 11:46 pm - Reply

    so basically getter are just return methods,

  12. emerlander November 6, 2019 at 11:46 pm - Reply

    Dude you are so amazing! Thank you!

  13. Jinxas Kao November 6, 2019 at 11:46 pm - Reply

    Having problems with 'return'.

    class Asmenybe {
    String vardas;
    int metai;

    void susipazindinimas() {
    for (int i = 1; i <= 7; i++) {
    System.out.println("As esu " + vardas + "man yra" + metai + "( " + i + " )");
    }

    }

    void pasisveikinimas() {
    System.out.print("Zdrw ");
    }

    void apskaiciavimasMetuIkiPensijos() {
    int metuLiko = 70 – metai;

    System.out.println(metuLiko);

    return metuLiko;
    }
    }

    public class App {

    public static void main(String[] args) {

    Asmenybe asmenybe1 = new Asmenybe();
    asmenybe1.vardas = "Tomas";
    asmenybe1.metai = 32;

    Asmenybe asmenybe2 = new Asmenybe();
    asmenybe2.vardas = "Billas";
    asmenybe2.metai = 35;

    System.out.println(asmenybe1.vardas + " " + asmenybe2.vardas);
    asmenybe1.pasisveikinimas();
    asmenybe1.susipazindinimas();
    asmenybe2.pasisveikinimas();
    asmenybe2.susipazindinimas();
    int metuLiko1 = asmenybe1.apskaiciavimasMetuIkiPensijos();
    System.out.println("Metai likusieji iki pensijos Tomui" + metuLiko1);
    // asmenybe2.susipazindinimas();

    }

    }

  14. Dom November 6, 2019 at 11:46 pm - Reply

    what's the difference when you tried to get the return value of age by the int getAge() and then store it to a variable 'age' to what I did which is simply storing person1.age to, say, int x = person1.age directly ?? THANKS !

  15. daniel edwards November 6, 2019 at 11:46 pm - Reply

    I am having problems with the Person class that was put on top of the App class . I am getting a duplicate error message.

  16. Yi Hao Xie November 6, 2019 at 11:46 pm - Reply

    what happens if I return the this keyword? how do I do it?

  17. Arpit Dutt Dixit November 6, 2019 at 11:46 pm - Reply

    difference between void and public void .

  18. Heat4Life November 6, 2019 at 11:46 pm - Reply

    Awesome!

  19. Bob Smith November 6, 2019 at 11:46 pm - Reply

    Eureka! I finally understand "Getters!" (Nevermind the dozen or so books I have on Java……….!)

  20. Sathvik Rachakulla November 6, 2019 at 11:46 pm - Reply

    how do you return three int values n,p,r at the end of a method to the main method.Please give me the syntax.Thanks.

  21. Bashir November 6, 2019 at 11:46 pm - Reply

    awesome I learned so much from this video

Leave A Comment

*