问题
I am learning Obj-C and discovered the @synthesize
directive which generates accessor and mutator methods.
Groovy auto-generates getters/setters but I'm not sure if Java does. Does Java have a similar feature in Java 7?
回答1:
As everyone has said, the answer is no, however Project Lombok could be of interest
回答2:
No, java does not come with such a feature.
回答3:
No, if I'm not mistaken, not yet at least.
回答4:
Though Java does not, to my knowledge, have such a feature defined, several Java coding environments (such as Eclipse) produce automatic getters and setters under certain circumstances.
来源:https://stackoverflow.com/questions/7956979/does-java-have-the-equivalent-of-synthesize-in-objective-c