yoda condition
Consider the following 2 conditions in Java
Example
public class Test { public static void main(String[] args) { String s; s = "yoda"; if (s == null) { } // yoda condition if (null == s) { } } }
They both result in the same behavior, but the second one has one advantage: It prevents you from accidentally changing a variable, when you forget one =. In that case the compiler returns an error at that row and you’re not left with some weird behavior of your code and the resulting debugging. The second condition is called a Yoda Condition