When I was learning Java, I had a Class that had a Enum property, and at one point I wanted to know if what was coming in a Method was equal to a Enum constant, something like this:
public void teste( TipoAlteracaoValor valor ) {
if( valor.equals(TipoAlteracaoValor.ALTERACAO_VALOR) ) {
System.out.println( "é Alteração ");
}
//Deveria ser assim:
if( TipoAlteracaoValor.ALTERACAO_VALOR.equals(valor)) {
System.out.println("é Alteração" );
}
}
But I was told that this is wrong to do, the right thing is to compare the Enum constant with the value that is coming from the parameter. But I do not remember ... what is the technical reason for using this comparison?