'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 ifs, loop never breaks , continues until finished, , variable result not take true value. think silly, can not see wrong.

you have double | , & in ifs.

|| means or
&& means and

| , & bitewise operators.

to clarify answer, break conditions seem fine me , real problem see in code operator mentioned.


Comments

Popular posts from this blog

java - Jmockit String final length method mocking Issue -

asp.net - Razor Page Hosted on IIS 6 Fails Every Morning -

c++ - wxwidget compiling on windows command prompt -