title: Way to print the variable name and variable value in java
body: <pre><code>String activityState = "resume";
  DebugLog(activityState)
  
  void DebugLog(String obj1) {}
  </code></pre>
  
  <p>How to make the <code>DebugLog</code> to print like this:</p>
  
  <pre><code>activityState : resume
  </code></pre>
  
  <p>I used to write many print statement as logs at many places while debugging. I will write statements like </p>
  
  <pre><code>System.out.println("activityState : " + activityState);
  </code></pre>
  
  <p>I want a method to print the variable name and variable value. In C++, it can be done like the below:</p>
  
  <pre><code>#define dbg(x) cout&lt;&lt; #x &lt;&lt;" --&gt; " &lt;&lt; x &lt;&lt; endl ;
  </code></pre>
  
  <p>Is there any way to do this?</p>
  
  <p>Thanks in advance. </p>