我有以下代码:
private boolean result = false;
public boolean checkHourExist(int hourfrom,
int minutefrom,
int hourto,
int minuteto,
int day,
int templateId)
{
List<templates> t = getAllTemplatesWithDays();
for (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;
}
当代码转到我if
的其中一个时,循环永远不会中断并继续直到完成,并且我的变量结果不采用真实值。我认为这可能很愚蠢,但我看不出有什么不对。