Java布尔if语句搞砸了

Hig*_*ce2 0 java calendar if-statement boolean hashmap

我有这个if语句,当我用JOptionPane.showMessageDialog检查时(如代码顶部所示)返回false,但块仍然执行.我看不出我应该做些什么不同.

变量:

  • c = GregorianCalendar
  • s =字符串
  • h = HashMap-array - 字符串,日期
  • oldGoods1,2和3 = HashMaps - String,Date

码:

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));
  }
}
Run Code Online (Sandbox Code Playgroud)

先谢谢Highace2

Roh*_*ain 9

if(c.after((Date) h[counter].get(s)));  // The `;` is the culprit. Remove it.
Run Code Online (Sandbox Code Playgroud)

在结尾处有一个分号,它只if statementif statement那里终止,并且无论条件评估的是什么,总是执行下面的块,它只是一个本地块.