(代碼約定文檔:http://www.oracle.com/technetwork/java/codeconventions-142311.html#449)語句代碼約定的if-else,在Java
我一直在寫if-else語句爲:
if(condition) {
statements;
} else {
statements;
}
然而,在Java代碼中約定文檔,它說,它這樣寫:
if (
condition) {
statements;
} else {
statements;
}
還有,我一直對語句這樣寫的:
for(initialization;condition;update) {
statements;
}
但編碼約定說:
for (
initialization;
condition;
update) {
statements;
}
縮進和間距似乎不必要的麻煩我。哪個是正確/更好的方式,爲什麼?
即我應該遵循約定嗎? – thatbennyguy
看來約定頁面有問題。請閱讀pdf: http://java.sun.com/docs/codeconv/CodeConventions.pdf –
O golly you win! :D – thatbennyguy