for循环的使用
[bo] 1 2 3 +4 5 6 -
7 8 9 *
0 / . =
用FOR循环实现按钮的创建(顺序)[/bo]
搜索更多相关的解决方案:
for
----------------解决方案--------------------------------------------------------
程序代码:
public JButton[] createButtons(){
String[] label = {"1","2","3","+","4","5","6","-","7","8","9","*","0","/",".","="};
JButton[] buttons = new JButton[16];
for(int i=0;i<label.length;i++){
buttons[i] = new JButton(label[i]);
}
return buttons;
}
String[] label = {"1","2","3","+","4","5","6","-","7","8","9","*","0","/",".","="};
JButton[] buttons = new JButton[16];
for(int i=0;i<label.length;i++){
buttons[i] = new JButton(label[i]);
}
return buttons;
}
----------------解决方案--------------------------------------------------------
太感谢啦!!!
----------------解决方案--------------------------------------------------------