Java布尔if语句出错

Java布尔if语句出错,java,if-statement,calendar,hashmap,boolean,Java,If Statement,Calendar,Hashmap,Boolean,我有一个if语句,当我使用JOptionPane.showMessageDialog(如代码顶部所示)进行检查时,返回false,但仍然执行该块。我看不出有什么不同。 变量: c=格里高利安达伦 s=字符串 h=HashMap数组-字符串,日期 oldGoods1、2和3=哈希映射-字符串、日期 代码: 事先谢谢 Highace2 if语句的末尾有一个分号,它只终止那里的if语句,并且无论条件的计算结果如何,始终执行下面的块(它只是一个局部块)。if语句后面有一个分号。代码的其余部分作为块执

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

变量:

  • c=格里高利安达伦
  • s=字符串
  • h=HashMap数组-字符串,日期
  • oldGoods1、2和3=哈希映射-字符串、日期
代码:

事先谢谢 Highace2


if语句
的末尾有一个分号,它只终止那里的
if语句
,并且无论条件的计算结果如何,始终执行下面的块(它只是一个局部块)。

if语句后面有一个分号。代码的其余部分作为块执行。一个相当常见的初学者错误。哦,该死的。。。我已经坐着找了3个小时了!无论如何,谢谢你的帮助。
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));
  }
}
if(c.after((Date) h[counter].get(s)));  // The `;` is the culprit. Remove it.