不确定为什么我得到这个错误...这是方法(我相信我正在返回所有必要的值)。有没有人知道我在语法上缺少什么,或者你认为这个问题比在这个堆栈跟踪中更大?为什么一个值没有被返回?
public bool equals(Object obj)
{
if (this == obj)
{
return true;
}
if (obj == null)
{
return false;
}
if (GetType() != obj.GetType())
{
return false;
}
AccountNumber anotherObj = (AccountNumber) obj;
if (failedCheckSum != anotherObj.failedCheckSum)
{
return false;
}
if (notValid != anotherObj.notValid)
{
return false;
}
if (line0 == null)
{
if (anotherObj.line0 != null)
{
return false;
}
else if (!line0.Equals(anotherObj.line0))
{
return false;
}
if (line1 == null)
{
if (anotherObj.line1 != null)
{
return false;
}
else if (!line1.Equals(anotherObj.line1))
{
return false;
}
}
if (line2 == null)
{
if (anotherObj.line2 != null)
{
return false;
}
else if (!line2.Equals(anotherObj.line2))
{
return false;
}
}
return true;
}
你会得到什么错误? – Leon
那么,你不是在告诉我们错误是什么,或者它是在哪条线上。我们不介意读者。顺便说一句,在方法中获得所有这些明确的回报是不好的做法。最好设置一个变量,然后在最后有一个返回值。 – OldProgrammer
您需要在最后一个语句之外再添加一个return语句 –