You can use double braces initialization: –
List<MyClass> list = new ArrayList<MyClass>() {
{
add(new MyClass("name", "address", 23));
add(new MyClass("name2", "address2", 45));
}
};
As you can see that, inner braces is just like an initializer block, which is used to initialize the list in one go..
Also note the semi-colon at the end of your double-braces