Why do you not declare several variables of the same type on the same line?

后端 未结 16 2246
梦谈多话
梦谈多话 2020-12-06 05:41

Why is it bad practice to declare variables on one line?

e.g.

private String var1, var2, var3

instead of:

private          


        
16条回答
  •  谎友^
    谎友^ (楼主)
    2020-12-06 05:44

    Here's my reasons:

    • Readability, easier to spot if you know there's only one on each line
    • Version control, less intra-line changes, more single-line additions, changes, or deletions, easier to merge from one branch to another

提交回复
热议问题