Java Programming Tutorial – 40 – Set and Get Methods

///Java Programming Tutorial – 40 – Set and Get Methods

Java Programming Tutorial – 40 – Set and Get Methods

FavoriteLoadingAdd to favorites

Website –
GitHub –
Reddit –
Twitter –
Facebook –
LinkedIn –
Instagram –

source

Java468x60
By |2020-10-05T09:46:40+00:00October 5th, 2020|Java Video Tutorials|34 Comments

34 Comments

  1. Yako Capital October 5, 2020 at 9:46 am - Reply

    Watching this in 2020

  2. Youssef Bayoumi October 5, 2020 at 9:46 am - Reply

    why do we need to create a get method we can use the variable hour and minute and second right away instead of creating a method that returns the variable and then call it ??

  3. Harry October 5, 2020 at 9:46 am - Reply

    is it poor practice to have user input inside setters ?

  4. The everything Channel October 5, 2020 at 9:46 am - Reply

    So this was uploaded august in 2009 !! Watching it in august 2019!!
    I like your style of teaching
    Easy , simple and small topic-wise videos makes learning easy !!

  5. PainsNotYourName October 5, 2020 at 9:46 am - Reply

    So im lost for the get methods… dont these methods have to take in hour and then return it? If the hour is already there arent you just returning the same thing? In other words whats the point od the get methods I dont get it.

  6. fdlfrs October 5, 2020 at 9:46 am - Reply

    What's the purpose of the get methods? Can't I just go straight to toMilitary?

  7. Cody King October 5, 2020 at 9:46 am - Reply

    Copied this code multiple times verbatim and it is giving me tons of errors. For some reason eclipse thinks the constructors are methods missing the type… I'm just going to pretend it worked and move on.

  8. Doris Hernandez October 5, 2020 at 9:46 am - Reply

    your videos have better explanations than my textbook

  9. hatim lachkare October 5, 2020 at 9:46 am - Reply

    i advice the beginners to start with c then c++ than java

  10. Mekonen S October 5, 2020 at 9:46 am - Reply

    I always said that the best teacher for new programmers is thenewboston. I wish I could meet him just to shake his glorious hand.

  11. Oscar Monroy October 5, 2020 at 9:46 am - Reply

    dope

  12. BlackAtomic October 5, 2020 at 9:46 am - Reply

    On Eclipse you can generate the getters and setters much faster.
    Source -> Generate Getters and Setters

    You're welcome

  13. 徐宏杰 October 5, 2020 at 9:46 am - Reply

    h h

  14. __ October 5, 2020 at 9:46 am - Reply

    Got. A burning question: could he have not written the get methods, taken out the void in the set method, and put the return in the get methods?

  15. Huseyin Altas October 5, 2020 at 9:46 am - Reply

    Bucky explained at end of this video what he did. "What the heck we just did here" :)))

  16. Ashish Karn October 5, 2020 at 9:46 am - Reply

    return String.format(……….)
    Is showing error in Eclipse SDK.
    What should i do?

  17. CatPerson95 October 5, 2020 at 9:46 am - Reply

    If you are using NetBeans (on windows) you can create the variables and press alt + insert, go to "getter and setter" option, select wich variables you want to use and NetBeans will create all the methods itself.

  18. Cody D October 5, 2020 at 9:46 am - Reply

    5:38 lol, right there

  19. Fares Ben ayed October 5, 2020 at 9:46 am - Reply

    when you're setting the hour why don't you write h%24 if the h value isn't in the [0, 24] .

  20. Karan Takkar October 5, 2020 at 9:46 am - Reply

    bucky can i do like this…

    int sethour(int h)
    {
    hour = ((h >= 0 && h < 24)? h : 0);
    return hour;
    }

    int setminute(int m)
    {
    minute = ((m >= 0 && m < 60)? m : 0);
    return minute;
    }

    int setsecond(int s)
    {
    second = ((s >= 0 && s < 60)? s : 0);
    return second;

  21. Al Dave October 5, 2020 at 9:46 am - Reply

    approximately 1% at school
    99% bucky's tut !! lol

  22. XOPGAMINGX October 5, 2020 at 9:46 am - Reply

    This is helping me to much !

  23. Avenger_ a a win October 5, 2020 at 9:46 am - Reply

    y dont he just
    public static void Settime(int h,int m,int s){
    hour = ((h>=0 && h<24) ? h : 0);
    minute = ((m>=0 && m<60) ? m : 0);
    second = ((s>=0 && s<60) ? s : 0);
    }

  24. Phil Rich Ama October 5, 2020 at 9:46 am - Reply

    when i tried to use c++ i was very confusing to type code, when i am starting to use Java, i have learned a lot of code from them, for my studying Im just made my own management system in simple program as beginner, i was really shocks because that not joke as beginner to build my own system. and then I saw this tutorial in 2017, he show me that the impossible code for statement it could be use in the other way. everyone please not just memorize the code just think about what is impossible to do by code.

  25. David Woods October 5, 2020 at 9:46 am - Reply

    Demonetized

  26. Caeli11 October 5, 2020 at 9:46 am - Reply

    Why do you have to create new methods for things like "return hour". For example in the toMilitary method, couldn't you just write hour instead of getHour() and return the function in that way. I am new to Java and it just seems like such a roundabout way of doing things to me. Thanks.

  27. Manu Chaudhary October 5, 2020 at 9:46 am - Reply

    can someone tell some simplest program to understand get and set method.

  28. First Name Last Name October 5, 2020 at 9:46 am - Reply

    Since it was never really explained, can someone explain to me what returning a variable/value really means? After the variables hour, minute, and second are set, why can't the variables just be called upon? Thanks

  29. Laserbean 00001 October 5, 2020 at 9:46 am - Reply

    Why can't we just use:
    public String toMilitary(){
    return String.format("%02d:%02d:%02d", hour(), minute(), second());

    }
    ?

  30. Daniel Neustadter October 5, 2020 at 9:46 am - Reply

    I don't GET this.

    GET it because GET method is the subject of this tutorial.

  31. Ein Hacker-Typ October 5, 2020 at 9:46 am - Reply

    So this must be a tutorial about encapsulation

  32. ngiw October 5, 2020 at 9:46 am - Reply

    one question: since only the last constructor used 'setTime' method, the input format wont be checked for valid if you uses other constructors that only have 'this'. Am I right?

  33. Yura Er October 5, 2020 at 9:46 am - Reply

    package bucky;

    public class tuna {
    private int hour;
    private int minute;
    private int second;

    public tuna(){
    this(0,0,0);
    }
    public tuna(int h){
    this(h,0,0);
    }
    public tuna(int h, int m){
    this(h,m,0);
    }
    public tuna(int h, int minute, int s){
    setTime(h,m,s);
    }
    public void setTime(int h, int minute, int s){
    setHour(h);
    setMinute(m);
    setSecond(s);
    }
    public void setHour(int h){
    hour = ((h>=0&&h<24)?h:0);
    }
    public void setMinute(int h){
    minute = ((m>=0&&m<60)?m:0);
    }
    public void setSecond(int h){
    second = ((s>=0&&s<60)?s:0);
    }
    public int getHour(){
    return hour;
    }
    public int getMinute(){
    return minute;
    }
    public int getSecond(){
    return second;
    }
    public String toMilitary(){
    return String.format("%02d:%02d:%02d", getHour(), getMonute(), getSecond());
    }
    }

  34. YouTuber October 5, 2020 at 9:46 am - Reply

    does not it have a set/get properties like c# ?

Leave A Comment

*