4

How to run a highlighted code only in IntelliJ IDEA? Sometimes you don't need to run the whole file and wants to just run the some numbers of code. Are there any such choices in IntelliJ IDEA?

Ahmed Ashour
  • 5,179
  • 10
  • 35
  • 56
malhajri2017
  • 43
  • 1
  • 4
  • Possible duplicate of [Evaluating many expressions at once in Intellij Idea](http://stackoverflow.com/questions/29340908/evaluating-many-expressions-at-once-in-intellij-idea) – shoover Mar 01 '17 at 00:28

1 Answers1

1

It's possible to evaluate arbitrary expressions (Run | Evaluate Expression):

To evaluate a code fragment, click the Code Fragment Mode button and fill in the Code Fragment text box.

You can also use the Scratches feature.

Since version 15 Java scratches are runnable.

Community
  • 1
  • 1
CrazyCoder
  • 389,263
  • 172
  • 990
  • 904