Answer the question
In order to leave comments, you need to log in
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
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.
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question