这个数组有什么作用menu?我知道构造函数是如何工作的,但不确定为什么这个数组“菜单”与类名相同:
public class Menu {
private String name;
private String description;
// what is the role of this static array??
// why its name is same as of the class ??
public static final Menu[] menus={
new Menu ("Breakfast", "brownrice \n Bread\n Coffee"),
new Menu ("lunch", "white rice \n Bread\n Coffee"),
new Menu ("dinner", "brownrice \n Bread\n Coffee"),
};
private Menu (String name, String description)
{
this.name=name;
this.description= description;
}
public String getDescription() {
return description;
}
public String getName() {
return name;
}
}
//any leads would be appreciated
慕尼黑5688855
小怪兽爱吃肉
相关分类