Java print string c equivalent

See English answer > java reflection: how to get the name of a variable? 7

#define printVar(var) cout<<#var<<"="<<var;

Print string values and their names

Solution

You can use Java 8 version: java reflection: how to get the name of a variable? Then print the variable name

You can print values using the following: system out. println(String.valueOf(var));

Through java reflection, you can get more information from variables, such as class name, package name, class properties, etc

The content of this article comes from the network collection of netizens. It is used as a learning reference. The copyright belongs to the original author.
THE END
分享
二维码
< <上一篇
下一篇>>