Reputation: 1377
I debugged my java code. It didn't give any errors.But when i executed it (it isn't giving errors either, but) the code didn't successfully terminate. This is very funny. But is that even possible?
Upvotes: 0
Views: 71
Reputation: 88747
Yes, your code can be syntactically correct (and thus might run without any errors) but may be semantically incorrect.
Assume the following:
public int add( int operand1, int operand2)
{
return operant1 - operand2;
}
This would run without errors but still be incorrect due to logic/implementation error.
So, it IS possible to get wrong results by otherwise smoothly running code.
Upvotes: 1
Reputation: 10115
Yes it is possible that code works when debugging and doesn't work when running. Two possible reasons I can think of right now are
Upvotes: 1
Reputation: 2414
sure, when the slowdown introduced by debugger does mask some race condition, but this normally only applies to multi-threading or networking code.
Upvotes: 1