public static boolean isCompatibleForMultiplcation(final Matrix a, final Matrix b)
{
if (a == null)
{
throw new IllegalArgumentException("a cannot be null");
}
if (b == null)
{
throw new IllegalArgumentException("b cannot be null");
}
if(!(a.getNumberofColumns()== b.getNumberOfRows()))
{
return false;
}
else
{
return true;
}
}
I am getting a 'Conditional Logic can be removed argument in checkstyle for the following method. I cannot seem to figure out why... Can someone give me a pointer?
It is complaining about this part right here :
if(a.getNumberofColumns() != b.getNumberOfRows())
{
return false;
}
else
{
return true;
}
Whenever you see yourself writing code like this you can easily replace it with a single line by just returning the condition from the if statement:
return a.getNumberofColumns() == b.getNumberOfRows();
This statement will return true
if the the number of columns for a and rows for b are equal, and false
otherwise.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With