Replace this if-then-else statement by a single return statement

前端 未结 6 1277
天命终不由人
天命终不由人 2020-12-21 01:13

While solving sonarQube issue i face the below warning,does any one tell me how to overcome this warning

Method:-

@Override
    public boolean equals         


        
6条回答
  •  萌比男神i
    2020-12-21 01:33

    Well, you can replace:

    if (divisionId != other.divisionId)
        return false;
    return true;
    

    with the equivalent:

    return divisionId == other.divisionId;
    

    This will return false if divisionId != other.divisionId and true otherwise.

提交回复
热议问题