CodeGym /Courses /Java Collections /IDEA: Evaluate expression

IDEA: Evaluate expression

Java Collections
Level 9 , Lesson 5
Available

"In addition to Watches, there's also a powerful feature called Evaluate Expression."

"You right-click a variable in the code and select Evaluate Expression in the menu. Or simply press Alt+F8."

"Then a magical window opens where you can calculate the value of any expression:"

IDEA: Evaluate expression - 1

"Here's what we get:"

IDEA: Evaluate expression - 2

"But I said that you can enter any expression there:"

IDEA: Evaluate expression - 3

"Or even this:"

IDEA: Evaluate expression - 4

"Or this:"

IDEA: Evaluate expression - 5

"You can view all of these variables, and you can see everything they refer to, etc."

"I think that this would be a very handy for large programs."

"Yep. But there's more."

"Want to use program data to execute arbitrary code while the program is running?"

"Wait, you can do that?"

"Sure. The CodeFragmentMode button lets you do that. Click this button to switch to a mode where you can enter entire code fragments that are several lines long."

IDEA: Evaluate expression - 6

"Here I used the sum5 variable, called the sum() method, declared a few variables, assigned values to them, and calculated the result of all this."

"What do you think?"

"Personally, I think that's super cool. Especially the ability to perform various actions using the current values of variables like sum5 and sum7. The ability to call methods and create variables means I can do practically anything."

"Yep. It's very cool. You can execute code and write stuff to the console — and it will be displayed! It's fully-functional code. Without any limitations."

"Thanks, Ellie. These have been some very informative and — I won't hesitate to say — most useful lessons ever."

Comments (3)
TO VIEW ALL COMMENTS OR TO MAKE A COMMENT,
GO TO FULL VERSION
Andrei Level 41
29 July 2021
I didn't find this CodeFragmentMode in Intellij, even looked using the search button at the top right part.
Isma Level 41, Madrid, Spain
6 September 2021
You have to left click here:
Isma Level 41, Madrid, Spain
6 September 2021
The mouse is not showing, it's on the expand message at the upper right section of the screen