Reputation: 27
public boolean createPricebreakupOrder(int x, int y) {
boolean returnFlag = false;
try {
if (x == y) {
returnFlag = true;
}
} catch (final Exception e) {
LOG.debug("Exception while Price Breakup Create" + e.getMessage());
returnFlag = false;
}
return returnFlag;
}
Now I am calling this method from two different classes; and passing the same parameter in, from each class. For the first class, the method is getting executed and returnFlag = true
. While for other, even with the same parameters, it is returning false.
Upvotes: 0
Views: 232
Reputation: 234875
Be assured that because the code in the try
block does not ever throw an exception, your function is equivalent to
public boolean createPricebreakupOrder(int x, int y)
{
return x == y;
}
There is nothing non-deterministic about this function: the same input parameters will yield the same result.
If x
and y
were actually Integer
types then it's possible that ==
will fail due to reference comparisons or, perhaps, an NPE is thrown when auto-unboxing a null
Integer
to an int
when the function is called.
Upvotes: 2