iv'e一直在四處搜尋,但很難找到針對此特定代碼的答案。我正在尋找使if語句搜索分隔符 - 然後使用將變量前後的整數應用於變量。例如。如果他們輸入了1-50,則它將1應用於int a,並將50應用於int b。以下是我希望應用它的if語句。它會來自輸入變量:如何獲得我的if語句以搜索分隔符?
if (yes.equalsIgnoreCase("no")){
if (a.equalsIgnoreCase(answer) && input.equalsIgnoreCase("instant")){
Thread.sleep(1);
}
else if (a.equalsIgnoreCase(answer) && input.equalsIgnoreCase("generate")){
Thread.sleep(randomInt);
}
else if (a.equalsIgnoreCase(answer) && !input.equalsIgnoreCase("generate") && !input.equalsIgnoreCase("instant")){
int x =Integer.parseInt(input);
x = x*60000;
Thread.sleep(x);
}
else if (a.equals("quit")){
System.exit(0);
}
else if (a.equals("Quit")){
System.exit(0);
}
else if (a.equals("")){
}
else{
JOptionPane.showMessageDialog(null,"Please check the answer then try again ");
i = i-2;
}
感謝您的任何幫助。
完美的作品,謝謝。 – Icy100 2012-02-22 19:40:52