我试图使用JOptionPane从for循环中获取一系列数字。 for循环工作正常我遇到了阵列的麻烦。我如何在JTextField中打印数字? 我的代码如下:
int value = Integer.parseInt(JOptionPane.showInputDialog("Please enter the amount of numbers you want to input"));
int[] holy = new int[value];
StringBuilder water = new StringBuilder();
for(int i = 1; i<=value; i++){
int num = Integer.parseInt(JOptionPane.showInputDialog("Enter a number"));
holy[i]= num;
}
for(int j = 0; j<holy.length; j++){
water.append(holy[j]);
tfholy.setText(water.toString());
}