括号

下列关键字后必须有大括号(即使代码块的内容只有一行):if, else, for, while, do, switch, try, catch, finally, with

  1. // not good
  2. if (condition)
  3. doSomething();
  4. // good
  5. if (condition) {
  6. doSomething();
  7. }