mardi 25 octobre 2016

Unexpected behavior when have return statment in If condition

I have a method, to test a string,

  public boolean teste()
    {
        if ( "com.br".equals("com.br") ) {
            //String teste = "1";
            return true;
        }
        return false;

    }

This method always return false, when debuging, the debugger says that it will never pass in the return true; line! IF I uncomment the String teste = "1"; then it will return true; Is that a Bug?

Aucun commentaire:

Enregistrer un commentaire