Actually, there is!
Person p = new Person()
{{
setFirstName("John");
setLastName("Doe");
setAddress(new Address()
{{
setStreet("1234 St.");
setCity("Phoenix");
}});
}};
or even:
Person p = new Person()
{{
firstName = "John";
lastName = "Doe";
address = new Address()
{{
street = "1234 St.";
city = "Phoenix";
}});
}};
This is called double brace initialization. However I would avoid this idiom as it has some unexpected side-effects, e.g. this syntax actually creates an anonymous inner class Person$1 and Address$.
See also
- What is Double Brace initialization in Java?
- Double Brace Initialization