i have MyClass as
MyClass(String, String, int);
i know about how to add to add to ArrayList in this way:
MyClass.name = \"N
You can use double braces initialization: -
List list = new ArrayList() {
{
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