Hig*_*ce2 0 java calendar if-statement boolean hashmap
我有这个if语句,当我用JOptionPane.showMessageDialog检查时(如代码顶部所示)返回false,但块仍然执行.我看不出我应该做些什么不同.
变量:
码:
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
if(c.after((Date) h[counter].get(s))); // The `;` is the culprit. Remove it.
Run Code Online (Sandbox Code Playgroud)
在结尾处有一个分号,它只if statement在if statement那里终止,并且无论条件评估的是什么,总是执行下面的块,它只是一个本地块.