Get the App
SLTechnology News&Howtos  ›  Development  › 

Sample Analysis of snippet Code in Intellij IDEA

Shulou Source: shulou.com Published: 2022-06-01 04:24:00 10月04日 Update

Editor to share with you the sample analysis of snippets of code in Intellij IDEA, I believe that most people do not know much about it, so share this article for your reference, I hope you can learn a lot after reading this article, let's go to know it!

Fragment code

I don't know what name to use to express this. Sometimes in the process of debugging, I suddenly want to entertain a section of code related to this, but not in the source file to observe and assist in problem analysis. Will you stop the program at this point, add the code, and run again?

There is a function in IDEA to execute code snippets that you temporarily write in the context of the current code.

For example, the current method passes in a List, but this method lacks an element that you need to use later conditions, so you can temporarily use the function executed by the snippet code to add one to it.

Note that in IntelliJ IDEA, the red box above, like a small calculator button, is a temporary function. After clicking, it will pop up the Evaluate Expression (Ctrl+F8) box below the button, enter the code, and click Evalute in the lower right corner. The return value is displayed at Result.

This is equivalent to temporarily changing the contents of the variable.

Then, you can also call the object's methods, perform functions, get property values, and so on.

The above is all the content of the article "sample Analysis of snippet Code in Intellij IDEA". Thank you for reading! I believe we all have a certain understanding, hope to share the content to help you, if you want to learn more knowledge, welcome to follow the industry information channel!

Tags: Code snippets functions analysis content methods articles examples buttons up and down context not much elements variables names most objects that is attributes time Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Shulou Tech Info Huawei macOS Docker Linux