0
我有這個if語句,當我檢查一個JOptionPane.showMessageDialog(如代碼頂部所示)返回false,但塊仍然執行。我看不到我應該做的不同。
變量:Java boolean if-statement up up
- C = GregorianCalendar的
- S =字符串
- H = HashMap的陣列 - 字符串,日期
- oldGoods1,2,和3 =包含HashMap - 字符串,日期
代碼:
JOptionPane.showMessageDialog(null, c.after((Date) h[counter].get(s)));
if(c.after((Date) h[counter].get(s))); //this line
{
Calendar today = Calendar.getInstance();
if(today.after((Date) h[counter].get(s)))
{
GoodsList.removeDate(s, (Date) h[counter].get(s));
}
if(!oldGoods1.containsKey(s))
{
oldGoods1.put(s, (Date) h[counter].get(s));
}
else if(!oldGoods2.containsKey(s))
{
oldGoods2.put(s, (Date) h[counter].get(s));
}
else if(!oldGoods3.containsKey(s))
{
oldGoods3.put(s, (Date) h[counter].get(s));
}
}
由於預先 Highace2
你的if語句後面有一個分號。其餘的代碼以塊的形式執行。一個相當普遍的初學者錯誤。 – Perception 2013-02-14 23:47:17