Posts

Showing posts from 2022

Short Circuit Problem when using conditional statements

 Just a little revision to my educational learnings, whenever we are writing the code with conditional statements, we encounter the issue of Short Circuit Problem. This can be avoided to clearly analyze our requirement of the condiition and do consider the SHORT CIRCUIT could result if condition is satsified. Consider the following example ! PASTED from the following LINK: https://stackoverflow.com/questions/9344305/what-is-short-circuiting-and-how-is-it-used-when-programming-in-java Short-circuiting is where an expression is stopped being evaluated as soon as its outcome is determined. So for instance: if (a == b || c == d || e == f) { // Do something } If  a == b  is true, then  c == d  and  e == f  are  never evaluated at all , because the expression's outcome has already been determined. if  a == b  is false, then  c == d  is evaluated; if  it's  true, then  e == f  is never evaluated. This may not...