I have a class that currently has several methods that take integer parameters. These integers map to operations that the application can perform. I\'d like to make the clas
The compiler can infer the type arguments on fields most of the time based on the type of the arguments passed:
import lombok.Data;
@Data
public class MyClass {
private T myField;
}
can be used as,
MyClass myClass = new MyClass();
String abc = "hello world !";
myClass.setMyField(abc);
System.out.println("test generic class with generic field = " + myGenericClass.getMyField());
and that should result into,
test generic class with generic field = hello world !