Why the strange indentation on switch statements?

后端 未结 6 1147
太阳男子
太阳男子 2021-02-04 23:11

Why is the imho missing indentation of the \"case\" - keywords in a switch statement considered good style?

No indentation of the \"case\" keyword seems to be the defaul

6条回答
  •  Happy的楠姐
    2021-02-04 23:52

    The 1999 official Oracle Code Conventions for the Java TM Programming Language (section 7.8) recommends a switch style where case statements are not indented relative to the switch statement as a whole.

    This is a subjective choice, but Sun decided it is better if everyone stick to one style, and picked this.

提交回复
热议问题