gpt4 book ai didi

java - JOptionPane 输入 for 循环,具有两个增量

转载 作者:行者123 更新时间:2023-12-02 07:08:33 24 4
gpt4 key购买 nike

好的,我在执行以下循环时遇到了问题。此循环的预期目标是 userinput[k] 是已在方法中按字母顺序排序的名称列表。这些名称随后将显示在下面的输入对话框中,其中将输入代表学位的数字。

我正在尝试将姓名和学位匹配起来。例如:在循环中,第一个用户输入将是 userinput[0]。我想要将数字输入到 bee Degree[0],然后依此类推....

问题是我如何使用 J 增量器存储该输入。所以我基本上得到的错误是 String Degree[] = Integer......

for ( int k = 0;  k < userinput.length;  k++ ){      
for (int j = 0; j < userinput.length; j++ ) {
String input = JOptionPane.showInputDialog("Please enter the highest earned degree for the following person : " + userinput [ k ] + "\n 1 = BS \n 2 = MS \n 3 = PhD");
String degree[] = Integer.parseInt(input[]);
}
}

最佳答案

这就是你想做的事吗?

int[] degree = new int[userInput.length];
for(int k = 0; k < userInput.length; k++) {
String input = JOptionPane.showInputDialog("Please enter the highest earned degree for the following person : " + userinput [ k ] + "\n 1 = BS \n 2 = MS \n 3 = PhD");
degree[k] = Integer.parseInt(input);
}

关于java - JOptionPane 输入 for 循环,具有两个增量,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/15822291/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com