public static void showMainMenu(String [] menus) {//数组menus作为形参
for (int i = 0; i < menus.length; i++) {
System.out.print(i+1+"."+menus[i]);
}
}
public static void main(String[] args) {
String [] menus = {"增加","修改","查询","删除","返回"};//定义好menus实参
MenuManager.showMainMenu(menus);//传参
}
public class MenuManager {
public static final String [] loginMenus = {
"登录","退出"
};
public static final String [] mainMenus = {
"增加","修改","查询","删除","返回"
};
public static void showMainMenu(String [] menus) {//数组menus作为形参
for (int i = 0; i < menus.length; i++) {
System.out.print(i+1+"."+menus[i]);
}
}
public static void main(String[] args) {
// String [] menus = {"增加","修改","查询","删除","返回"};//定义好menus实参
MenuManager.showMainMenu(mainMenus);//传参
MenuManager.showMainMenu(loginMenus);//传参
}
}