我确定有一个答案,但我似乎无法找到它,我一直在寻找几个小时。测试X = A,B或C
标题几乎总结起来,如何测试,如果X = A,B或C
Qhey = “嘿”;
Qhi =“hi”;
Qhello =“hello”;
我这一小段代码:
if(InputField.getText().contains(Qhey))
{
try {
textArea.getDocument().insertString(0,Qhello +", todays date is "+day+"/"+month+"/"+year + "\n", null);
}catch (BadLocationException ex) {
Logger.getLogger(ClassStart.class.getName()).log(Level.SEVERE, null, ex);
}
}
,我想让它是这样的:
if(InputField.getText().contains(Qhey, Qhi, Qhello))
{
try {
textArea.getDocument().insertString(0,Qhello +", todays date is "+day+"/"+month+"/"+year + "\n", null);
}catch (BadLocationException ex) {
Logger.getLogger(ClassStart.class.getName()).log(Level.SEVERE, null, ex);
}
}