Java – Lombok: how to specify an Arg constructor?
•
Java
With Lombok, can you specify an Arg constructor?
My goal is to create a constructor using the Lombok annotation, as shown below
class MyClass { private String param; private Integer count; public MyClass(String param) { this.param = param; } }
Solution
how: http://projectlombok.org/features/Constructor.html ?
You must initialize all variables that should not be constructors
Therefore, a parameter (param) constructor should be created below:
@requiredArgsConstructor class MyClass { private String param; private Integer count = -1; }
The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
二维码