vendredi 4 décembre 2015

Confusing indentation, why and how it can happen

This is actually not a problem for solving but I felt curious that why the following code would gives the confusing indentation warning for possible missing of surrounding block:

                      if(x!=y)
                      System.out.println("not equal"); 
                      index++;

If I put the System.out.println("not equal"); inside {} the warning would go away but I feel curious in what situation the current looking code would go wrong.

Aucun commentaire:

Enregistrer un commentaire