Constant value should always come first in comparison

Normal practice Constant value comes second in comparison. private static final String COMPARE_VALUE = "VALUE123"; public boolean compareIt(String input){ if(input.equals(COMPARE_VALUE)){ return true; }else{ return false; } } Problem This is fine to compare a constant value with the above method, however it will potentially causing a NullPointerException, if user pass a “null” value for the …

Read more