For simple methods that do not have many checks on the Boolean conditions, it’s usually fine to simply return true
or false
.
boolean methodName(..arguments) {
return <checkCondition>
}
The above snippet is a reduction of your code’s intent (I say intent because yours will always return false).
For more complex functions, a common rule of thumb is to assign a return variable, similar to what you’ve provided; having too many return statements can be harder to maintain.
This all said, it typically boils down to coding standards maintained by the software team.
solved How do we return a boolean variable from a method?