tha*_*guy 3 java for-loop if-statement conventions
(代码约定doc:http://www.oracle.com/technetwork/java/codeconventions-142311.html#449)
我总是把if-else语句写成:
if(condition) {
statements;
} else {
statements;
}
Run Code Online (Sandbox Code Playgroud)
但是,在Java代码约定文档中,它表示如下所示:
if (
condition) {
statements;
} else {
statements;
}
Run Code Online (Sandbox Code Playgroud)
而且,我总是写这样的陈述:
for(initialization;condition;update) {
statements;
}
Run Code Online (Sandbox Code Playgroud)
但编码惯例说:
for (
initialization;
condition;
update) {
statements;
}
Run Code Online (Sandbox Code Playgroud)
压痕和间距对我来说似乎不必要的麻烦.哪个是正确/更好的方式,为什么?
Dan*_*ark 10
我认为这可能只是该HTML页面上的格式化问题?
看看PDF,我觉得它看起来更好:
http://www.oracle.com/technetwork/java/codeconv-138413.html
在那里,他们的条件与if在同一条线上.