📜  如何在 java 中使用 if else 的组合框 - Java 代码示例

📅  最后修改于: 2022-03-11 14:52:35.598000             🧑  作者: Mango

代码示例1
//using a combobox to do basic sums
int iNum1 = 420;
int iNum2 = 69;

if (combobox.getSelectedItem().equals("Add")) 
  int iAns = iNum1 + iNum2;
else if (combobox.getSelectedItem().equals("Subtract")) 
  int iAns = iNum1 - iNum2;