Java Beginner Programming Tutorial 41 Proper Getters And Setters

preview_player
Показать описание
How to create proper getters and setters
Рекомендации по теме
Комментарии
Автор

That's what I like about your tuts is that you teach us how simple code is. LIke you said, other tutorials make it seem so complicated. Thanks Anthony!

anljdfvcwafd
Автор

Omg you teach this way easier than my prof...

DisFlo
Автор

Why did you put the object declaration outside of main?

anljdfvcwafd
Автор

always better to make the setter to return boolean value, in case if in the future you will want to make some condition for the name.
Example:

public boolean setName(String name){
    this.name = name;
    return true;
}

maxnovikov
Автор

I'm confused, in the getName this statement, why does it return the local "name" that is set by the setName Method and not the null value in the global "name" that was initially declared? 

firebolt