+ 1

What are setters and getters in java

I forgot about them as I did them many months ago. I need to relearn them

15th Jul 2025, 10:11 AM
Aneerudh Singh
Aneerudh Singh - avatar
2 Réponses
+ 5
In Java, setters and getters are methods used to control access to the private fields of a class, encapsulating the data. Getters (also known as accessor methods) retrieve the value of a private field, typically named getFieldName(). Setters (also known as mutator methods) modify the value of a private field, typically named setFieldName(newValue). This approach https://www-crediblebh.com allows for validation or other logic to be applied when data is accessed or modified, promoting better data integrity and object-oriented design principles.
15th Jul 2025, 12:04 PM
Crystal Roberts
+ 1
In case you forgot the course material, you can always read and do the lesson again. Just remember it won't add to your streak.
15th Jul 2025, 2:47 PM
Wong Hei Ming
Wong Hei Ming - avatar