Intellij IDEA's Expression Evaluation dialog has a button to enable Code Fragment Mode, which permits multi-statement evaluations. (I'm using version 9.0.2 of the Ultimate Edition.)


Same as @Noel answer, but some more details. First of all, Expression Evaluation (ALT + F8) can be enabled only in debug mode.

enter image description here

enter image description here


IntelliJ IDEA 13 Community Edition, Windows:

  1. Go to Debug mode and run the application
  2. Go to Evaluate Expression:

    enter image description here

    or right click in the editor area:

    enter image description here

  3. Go to Code Fragment Mode enter image description here

  4. Type your statements and click on Evaluate enter image description here