K
K
Kuusandr2019-12-01 11:15:23
Java
Kuusandr, 2019-12-01 11:15:23

How do getter/setter mechanisms work in Java?

While studying Java, I came across the fact that when explaining the properties of classes (property), textbooks prescribe to write getters and setters. After c# where you can clearly see that when you call properties, what and how is automatically called.
I wondered how this mechanism works in Java. Automatically or do you need to work with getters/setters manually? If there is automatic firing, how are the getters/setters linked to the property variable?
If there is sensible material, plz throw a link.

Answer the question

In order to leave comments, you need to log in

2 answer(s)
D
Denis Zagaevsky, 2019-12-01
@Kuusandr

In Java, the fields are not property. These are fields, they just contain something, like variables. Getters and setters must be written separately by hand. There is code generation in the IDE for this, and there are also libraries that generate code, like AutoValue.

R
Romulus, 2019-12-02
@Renee

Here I am taking a course with them
https://javarush.ru/groups/posts/1928-getterih-is...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question