There might be use case where sometime we want to access private members or do some processing with existing members or changes some component configuration while initialize an object.
Solution: – Write an Anonymous class with new method having your all required statements. Then add return statement with “this” in the end of the method and finally call same new method after anonymous class declaration is done.
ConfirmDialog confirmationDialog = new ConfirmDialog(message)
{
public ConfirmDialog setPrivateCheckBoxWidget()
{
_privateCheckBox.setText("Changing default text");
_privateCheckBox.setSelected(true);
return this;
}
}.setPrivateCheckBoxWidget();