I had an interesting conversation with one of my team mate.
Is CONSTANT.equals(VARIABLE) faster than VARIABLE.equals(CONSTANT)in Java?
CONSTANT.equals(VARIABLE)
VARIABLE.equals(CONSTANT)
One good comparison can be:
private static String EXAMPLE = "Example"; private String obj = null;
case 1:
if(obj.equals(EXAMPLE) { }
This is throw null pointer exception..
case 2 :
if(EXAMPLE.equals(obj)) { }
This will not throw null pointer exception..