Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Intellij is it possible to show value of static variables?

Let's say I have the following code:

System.out.println(Math.PI);

Is there a plugin or some setting where I can hover over Math.PI and have IntelliJ tell me the value of the constant?

like image 507
alexgbelov Avatar asked Oct 12 '16 23:10

alexgbelov


People also ask

How can I see variable values in IntelliJ?

Step Over (F8) lets you execute a line of code and move on to the next line. As you step through the code, you'll see the value of the variables next to the code in the editor window. These values are also visible in the Variables pane in the Debug window.

Can you access a static variable?

Static variables can be accessed by calling with the class name ClassName. VariableName. When declaring class variables as public static final, then variable names (constants) are all in upper case. If the static variables are not public and final, the naming syntax is the same as instance and local variables.

How do you read a static variable?

A static variable is common to all the instances (or objects) of the class because it is a class level variable. In other words you can say that only a single copy of static variable is created and shared among all the instances of the class.

Do static variables keep their value?

Static variables are known to retain the value even after they exit the scope. They retain their value and are not initialized again in the new scope. This article will help you explore Static variable in C.


2 Answers

Press ctrl + q (or ctrl + j on mac) to activate the quick documentation action to see a documentation popup for this constant:

enter image description here

Also you could hover over PI with pressed ctrl:

enter image description here

Furthermore, you always can jump to the source code by ctrl + b.

enter image description here

like image 129
Andrew Tobilko Avatar answered Sep 27 '22 18:09

Andrew Tobilko


It's much better to use View Definition feature.

enter image description here

By hitting Ctrl+Shift+I (if you're OSX user Option+Space) you will see the method, function, constant, variable definition in window popup.

Example with Objects#equals method:

enter image description here

like image 20
Anton Dozortsev Avatar answered Sep 27 '22 16:09

Anton Dozortsev