To keep code minimal, I want to be able to create a list of a custom object in java. Similar to what we do in C# or Swift, where we define the constructor or parameters of the list in that way we don't have to create a separate object and constructor for the list.
For example
var menuList: [(category: String, name: String, ismulti: Bool)] = [
(category: "Categ1", name: "name1", ismulti: true),
(category: "Categ2", name: "name2", ismulti: false),
(category: "Categ3", name: "name3", type: ismulti: true),
]
Here var menuList: [(category: String, name: String, ismulti: Bool)] reduced the need for object and constructor. Is there something similar in java?
for same what I did in java.
public class Menu{
String category;
String name;
boolean isMulti;
public Menu(String category, String name, boolean isMulti) {
this.category = category;
this.name = name;
this.isMulti = isMulti;
}
public List<Menu> menuList = new ArrayList<Menu>() {{
add(new Menu("categ1","name1",true));
add(new Menu("categ2","name2",true));
add(new Menu("categ3","name3",true));
}};
}