I have this if-statement that when I check with a JOptionPane.showMessageDialog (as seen in top of the code) returns false but the block is still executed. I cannot see what I should do different.
Variables:
- c = GregorianCalendar
- s = String
- h = HashMap-array – String, Date
- oldGoods1, 2, and 3 = HashMaps – String, Date
Code:
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));
}
}
Thanks beforehand
Highace2
There is a semi-colon at the end of the
if statement, which terminates theif statementthere only, and the following block which is just a local block, is always executed regardless of what the condition evaluates to.