String yearString=JOptionPane.showInputDialog("Enter year");
int year=Integer.parseInt(yearString);
String monthString=JOptionPane.showInputDialog("Enter month");
int month=Integer.parseInt(yearString);
String dayString=JOptionPane.showInputDialog("Enter day");
谁能不能帮我将这段程序缩写一下,看着太冗长了 谢谢
------解决方案--------------------
String[] str=new String[]{"Enter year","Enter month","Enter day"};
int[]times=new int[3];
for(int i=0;i<str.length;i++){
times[i]=Integer.parseInt(JOptionPane.showInputDialog(str[i]));
}