I had an interesting conversation with one of my team mate.
Is CONSTANT.equals(VARIABLE)
faster than VARIABLE.equals(CONSTANT)
in Java?
That depends only on the implementation of the equals method. It could be quicker, it could be the slower and it could be the same... Often it is the same. Also it does not depend on the fact that one is a variable and the other a constant but on the content both objects.
One advantage of Constant.equals(variable) is that you can't have a NullPointerException on the .equals