K&R 스타일 사용 (여는 중괄호를 줄의 끝에 배치, 닫는 중괄호를 엔터치고 입력)
return () -> {
while (condition()) {
method();
}
};
빈 블록은 간결하게 작성 가능 ({}
)
// This is acceptable
void doNothing() {}
// This is equally acceptable
void doNothingElse() {
}
// This is not acceptable: No concise empty blocks in a multi-block statement
try {
doSomething();
} catch (Exception e) {}
2칸 들여쓰기
if (condition) {
doSomething();
} else {
doSomethingElse();
}
메서드 체인(여러 메서드를 연이어 호출)의 경우 4칸 들여쓰기
String result = someObject
.methodOne()
.methodTwo()
.methodThree();