I want to set a value of a private field with double brackets initializer. The next is working
Customer customer1 = new Customer();
customer1.setFirstName("Nick");
This is also working:
Customer customer3 = new Customer("John", "Hammond", true, 80, "3/4/1978");
I also want to set the value of the private field with something like this. I know this is not the correct way. Is there any correct way to do this?
Customer customer2 = new Customer()
{
{
firstName = setFirstName("George");
}
};