Getter and Setter

Today in class we learned the nuances of coding, through getter and setter methods. This method allows us to be able to object traits, such as height, gender, etc. Getter and setter methods rely on the use of datatypes, so during the process, it is essential for the user to put in the right datatypes.

int = number

double = decimals

boolean = true/false

char = letter

Finally, after you define the getter and setter methods, you need to add a return value, which like the words says returns whatever you have stored in the object. The computer is dumb in the way that you have to explain to the computer that these variables need to be printed.

Leave a Reply

Your email address will not be published. Required fields are marked *