I wonder when idx is -1 why this causes the runtime exception. It says the array cannot access cause idx is -1. But in my thought, idx -1 doesn't match the first condition (idx >= 0) so it should skip the next condition (open[idx] ,,,)
if ((idx >= 0) && (open[idx] == '(') || (open[idx] == '{')) {
However, this code pass
if ((idx >= 0) && ((open[idx] == '(') || (open[idx] == '{'))) {
I cannot understand why two conditional statements work differently. Please help me explain. Thanks
Aucun commentaire:
Enregistrer un commentaire