'for' loop break in Java is not working -
i have below piece of code:
private boolean result = false; public boolean checkhourexist(int hourfrom, int minutefrom, int hourto, int minuteto, int day, int templateid) { list<templates> t = getalltemplateswithdays(); (templates tem : t) { if(day == -1 | tem.temp_dayid == day) { if(tem.temp_hourfrom >= hourfrom & tem.temp_hourto == hourto ) { if(tem.temp_hourfrom == hourfrom) { if(tem.temp_minfrom == minutefrom ) { result= true; break; } else if(minutefrom < tem.temp_minfrom & minuteto >= tem.temp_minto ) { result = true; break; } } else { result = true; break; } } else if(tem.temp_hourfrom == hourfrom & tem.temp_hourto < hourto ) { result = true; break; } else if(tem.temp_hourfrom > hourfrom & tem.temp_hourto < hourto ) { result = true; break; } } } return result; }
when code goes 1 of if
s, loop never breaks , continues until finished, , variable result not take true value. think silly, can not see wrong.
you have double |
, &
in if
s.
||
means or
&&
means and
|
, &
bitewise operators.
to clarify answer, break
conditions seem fine me , real problem see in code operator mentioned.
Comments
Post a Comment