(七) 控制语句
if (condition) statements;if (condition) { ... return obj; } // 接着写else的业务逻辑代码;public void today() { if (isBusy()) { System.out.println(“change time.”); return; } if (isFree()) { System.out.println(“go to travel.”); return; } System.out.println(“stay at home to learn Alibaba Java Coding Guidelines.”); return; }// 伪代码如下 final boolean existed = (file.open(fileName, "w") != null) && (...) || (...); if (existed) { ... }if ((file.open(fileName, "w") != null) && (...) || (...)) { ... }
Last updated