Java print string C++ equivalent

c++, java, string

Solution

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...

Problem

What would be the equivalent in java of C++ code: ``` #define printVar(var) cout<<#var<<"="<<var; ``` printing string value and its name .

Original source

Related problems