what is the error of the following code? why it always returns true?
Code:public boolean validate()
{
boolean valid = false;
if((hh>=0 || hh<=23)&&(mm>=0 || mm<=59)&&(ss>=0 || ss<=59))
valid=true;
return valid;
}
Printable View
what is the error of the following code? why it always returns true?
Code:public boolean validate()
{
boolean valid = false;
if((hh>=0 || hh<=23)&&(mm>=0 || mm<=59)&&(ss>=0 || ss<=59))
valid=true;
return valid;
}
Hi. what did you enter for variables mm, ss, hh?
Now It looks correct.
Also, you can just "return ((hh>=0......". No need to create a variable to hold it, if all it does is return it. And if you really want the variable to return, you can use "boolean valid=((hh>=0...".