Hi all,
Based on K&B 1.5 p318 �...Java law decrees that an else clause belongs to the innermost if to which it might possibly belong(..., the closest preceding if that doesn�t have an else.)..."
I thought, the last else would belong to if ( x == 5 ) since it did not have an else, but compile error: �else� without �if� is given. The
pattern is �if, if, else, if, else, else�, which I see indented as
Commenting out lines 6, 7, 10, and 11 which gives �if, if, else, else� pattern, will compile and run. Both cases have equal number of if�s and else�s. Which I see as:
Soooo why doesn�t line 10�s else match up with line 1�s if? Isn�t it the closest if without an else?
Richard