What would be the equivalent in java of C++ code:
#define printVar(var) cout<<#var<<"="<<var;
printing string value and its name .
You can print the variable name since Java 8 version: Java Reflection: How to get the name of a variable?
You can print the value using something like: System.out.println(String.valueOf(var));
Through Java reflection you can get more information from a variable, such as class name, package name, class attributes, etc...
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With