我创建了一个 JOptionPane 作为选择方法。我想要字符串数组中选择 1,2 或 3 的 int 值,以便可以将其用作计数器。如何获取数组的索引并将其设置为等于我的 int 变量loanChoice?
public class SelectLoanChoices {
int loanChoice = 0;
String[] choices = {"7 years at 5.35%", "15 years at 5.5%",
"30 years at 5.75%"};
String input = (String) javax.swing.JOptionPane.showInputDialog(null, "Select a Loan"
,"Mortgage Options",JOptionPane.QUESTION_MESSAGE, null,
choices,
choices[0]
**loanChoice =**);
}